{"record":{"id":"a7c7171a7b0547ee","repo":"justauth/JustAuth","slug":"object-getstring-error-description-a7c717","errorCode":null,"errorMessage":"object.getString(\"error_description\")","messagePattern":"object\\.getString\\(\"error_description\"\\)","errorType":"exception","errorClass":"AuthException","httpStatus":null,"severity":"error","filePath":"src/main/java/me/zhyd/oauth/request/AuthGitlabRequest.java","lineNumber":75,"sourceCode":"            .uuid(object.getString(\"id\"))\n            .username(object.getString(\"username\"))\n            .nickname(object.getString(\"name\"))\n            .avatar(object.getString(\"avatar_url\"))\n            .blog(object.getString(\"web_url\"))\n            .company(object.getString(\"organization\"))\n            .location(object.getString(\"location\"))\n            .email(object.getString(\"email\"))\n            .remark(object.getString(\"bio\"))\n            .gender(AuthUserGender.UNKNOWN)\n            .token(authToken)\n            .source(source.toString())\n            .build();\n    }\n\n    private void checkResponse(JSONObject object) {\n        // oauth/token 验证异常\n        if (object.containsKey(\"error\")) {\n            throw new AuthException(object.getString(\"error_description\"));\n        }\n        // user 验证异常\n        if (object.containsKey(\"message\")) {\n            throw new AuthException(object.getString(\"message\"));\n        }\n    }\n\n    /**\n     * 返回带{@code state}参数的授权url，授权回调时会带上这个{@code state}\n     *\n     * @param state state 验证授权流程的参数，可以防止csrf\n     * @return 返回授权地址\n     * @since 1.11.0\n     */\n    @Override\n    public String authorize(String state) {\n        return UrlBuilder.fromBaseUrl(super.authorize(state))\n            .queryParam(\"scope\", this.getScopes(\"+\", false, AuthScopeUtils.getDefaultScopes(AuthGitlabScope.values())))","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/justauth/JustAuth/blob/694bbf1b010d93404e3bfb4824d90e9ddfaebebb/src/main/java/me/zhyd/oauth/request/AuthGitlabRequest.java#L57-L93","documentation":"First branch of AuthGitlabRequest.checkResponse(): a GitLab token-endpoint failure is signaled by an 'error' key (standard OAuth2 envelope), and JustAuth throws AuthException with 'error_description' - e.g. 'invalid_grant' plus explanation from GitLab.","triggerScenarios":"getAccessToken()/refresh() with wrong application id/secret, redirect URI not in the GitLab app's trusted list, or an expired/replayed authorization code - GitLab returns {\"error\":\"...\",\"error_description\":\"...\"}.","commonSituations":"Self-hosted GitLab where the callback URL was configured on a different external URL than the one in AuthConfig; application secret regenerated; user revoked the application so refresh tokens no longer work.","solutions":["Open the GitLab application settings and confirm the callback URL equals AuthConfig.redirectUri exactly.","Re-copy the Application ID and Secret after any app change.","Handle 'invalid_grant' on refresh by deleting stored tokens and sending the user through authorize() again.","For self-hosted instances, verify the instance is reachable over HTTPS with a valid certificate - token exchange fails otherwise."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    return gitlabRequest.getAccessToken(callback);\n} catch (AuthException e) {\n    String m = String.valueOf(e.getErrorMsg());\n    if (m.contains(\"redirect\")) {\n        throw new ConfigurationException(\"GitLab callback URL mismatch - check application settings\", e);\n    }\n    if (m.contains(\"invalid_grant\")) {\n        return redirectToReauthorize();\n    }\n    throw e;\n}","preventionTips":["For self-hosted GitLab, configure the external_url exactly as used in AuthSource and the app callback.","Store refresh tokens; on 'invalid_grant' during refresh, clear sessions and re-authorize instead of retrying.","Verify TLS certificates on self-hosted instances - failed cert validation surfaces as token-endpoint errors."],"tags":["oauth","gitlab","justauth","api-error","token-exchange"],"backgroundTag":null,"analyzedSha":"694bbf1b010d93404e3bfb4824d90e9ddfaebebb","analyzedAt":"2026-08-14T15:16:59.945Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}