{"record":{"id":"fcb2d8158c6d9691","repo":"justauth/JustAuth","slug":"object-getstring-error-object-getstring","errorCode":null,"errorMessage":"object.getString(\"error\") + \":\" + object.getString(\"message\")","messagePattern":"object\\.getString\\(\"error\"\\) \\+ \":\" \\+ object\\.getString\\(\"message\"\\)","errorType":"exception","errorClass":"AuthException","httpStatus":null,"severity":"error","filePath":"src/main/java/me/zhyd/oauth/request/AuthFigmaRequest.java","lineNumber":115,"sourceCode":"            .rawUserInfo(dataObj)\n            .uuid(dataObj.getString(\"id\"))\n            .username(dataObj.getString(\"handle\"))\n            .avatar(dataObj.getString(\"img_url\"))\n            .email(dataObj.getString(\"email\"))\n            .token(authToken)\n            .source(source.toString())\n            .build();\n    }\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\") + \":\" + object.getString(\"message\"));\n        }\n    }\n}\n","sourceCodeStart":97,"sourceCodeEnd":119,"githubUrl":"https://github.com/justauth/JustAuth/blob/694bbf1b010d93404e3bfb4824d90e9ddfaebebb/src/main/java/me/zhyd/oauth/request/AuthFigmaRequest.java#L97-L119","documentation":"AuthFigmaRequest.checkResponse() throws when the Figma OAuth response contains an 'error' key; the message concatenates error + ':' + message (e.g. 'invalid_grant:Code already redeemed'). It guards both the token endpoint and the user endpoint.","triggerScenarios":"Exchanging the authorization code or fetching the Figma user with a wrong client_secret, an already-used code, or a redirect_uri mismatch - Figma returns the standard OAuth2 {error, error_description/message} envelope.","commonSituations":"Redeeming the code twice after the callback page is reloaded; the OAuth client secret was regenerated in Figma's account settings; the redirect URI in AuthConfig differs from the one on the Figma app page.","solutions":["Split the thrown message on ':' - the left part is the OAuth2 error code, the right part the human text.","Exchange the code exactly once per callback; use the state parameter or a nonce to detect replays.","Re-copy client_id/client_secret/redirect_uri from the Figma app settings page after any credential change.","Handle 'invalid_grant' by discarding stored tokens and redirecting the user to re-authorize."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    return figmaRequest.getAccessToken(callback);\n} catch (AuthException e) {\n    String m = String.valueOf(e.getErrorMsg());\n    if (m.startsWith(\"invalid_grant\")) {\n        return redirectToReauthorize(); // code already redeemed or expired\n    }\n    throw e;\n}","preventionTips":["Make callback handlers idempotent on the state parameter so a code is never redeemed twice.","Re-sync client_id/secret/redirect_uri from the Figma app page after any settings change.","Map OAuth2 error codes (invalid_grant, invalid_client, redirect_uri_mismatch) to distinct handling paths."],"tags":["oauth","figma","justauth","api-error","token-exchange"],"backgroundTag":null,"analyzedSha":"694bbf1b010d93404e3bfb4824d90e9ddfaebebb","analyzedAt":"2026-08-14T15:16:59.945Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}