{"record":{"id":"70f6ee847c5de13e","repo":"justauth/JustAuth","slug":"object-getstring-error-description-70f6ee","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/AuthGiteeRequest.java","lineNumber":75,"sourceCode":"            .nickname(object.getString(\"name\"))\n            .company(object.getString(\"company\"))\n            .location(object.getString(\"address\"))\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    /**\n     * 检查响应内容是否正确\n     *\n     * @param object 请求响应内容\n     */\n    private void checkResponse(JSONObject object) {\n        if (object.containsKey(\"error\")) {\n            throw new AuthException(object.getString(\"error_description\"));\n        }\n    }\n\n    /**\n     * 返回带{@code state}参数的授权url，授权回调时会带上这个{@code state}\n     *\n     * @param state state 验证授权流程的参数，可以防止csrf\n     * @return 返回授权地址\n     */\n    @Override\n    public String authorize(String state) {\n        return UrlBuilder.fromBaseUrl(super.authorize(state))\n            .queryParam(\"scope\", this.getScopes(\" \", true, AuthScopeUtils.getDefaultScopes(AuthGiteeScope.values())))\n            .build();\n    }\n}\n","sourceCodeStart":57,"sourceCodeEnd":92,"githubUrl":"https://github.com/justauth/JustAuth/blob/694bbf1b010d93404e3bfb4824d90e9ddfaebebb/src/main/java/me/zhyd/oauth/request/AuthGiteeRequest.java#L57-L92","documentation":"AuthGiteeRequest.checkResponse() implements the standard OAuth2 error check: any 'error' key in a Gitee response triggers AuthException with the 'error_description' text. It fires on token acquisition, refresh, and user-info calls.","triggerScenarios":"getAccessToken()/refresh()/getUserInfo() with incorrect client credentials, a reused authorization code, or a revoked/expired access token - Gitee answers {\"error\":\"...\",\"error_description\":\"...\"}.","commonSituations":"Gitee OAuth app secret regenerated without updating config; redirect_uri with mismatched case or trailing slash compared to the app settings; access token past its 1-day validity with no refresh flow.","solutions":["Align client_id/client_secret with the Gitee application settings and re-save config.","Make redirect_uri in AuthConfig match the Gitee app's callback address exactly.","Call refresh() with the stored refresh_token when error_description mentions an invalid token.","Consume each code once and handle duplicate callbacks idempotently."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    return giteeRequest.getUserInfo(token);\n} catch (AuthException e) {\n    if (String.valueOf(e.getErrorMsg()).contains(\"token\") || String.valueOf(e.getErrorMsg()).contains(\"grant\")) {\n        return giteeRequest.refresh(AuthToken.builder().refreshToken(refreshToken).build());\n    }\n    throw e;\n}","preventionTips":["Gitee access tokens are short-lived (about 1 day): persist and use the refresh token proactively.","Keep the redirect_uri byte-identical to the Gitee app registration (watch case and trailing slashes).","Rotate secrets through config, and alert on error_description containing 'invalid_client'."],"tags":["oauth","gitee","justauth","api-error","token-expired"],"backgroundTag":null,"analyzedSha":"694bbf1b010d93404e3bfb4824d90e9ddfaebebb","analyzedAt":"2026-08-14T15:16:59.945Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}