{"record":{"id":"fd51da8d522b2b82","repo":"justauth/JustAuth","slug":"object-getstring-error-description","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/AuthElemeRequest.java","lineNumber":174,"sourceCode":"        HttpHeader httpHeader = new HttpHeader();\n        httpHeader.add(\"Accept\", \"text/xml,text/javascript,text/html\");\n        httpHeader.add(Constants.CONTENT_TYPE, contentType);\n        httpHeader.add(\"Accept-Encoding\", \"gzip\");\n        httpHeader.add(\"User-Agent\", \"eleme-openapi-java-sdk\");\n        httpHeader.add(\"x-eleme-requestid\", requestId);\n        if (auth) {\n            httpHeader.add(\"Authorization\", this.getBasic(config.getClientId(), config.getClientSecret()));\n        }\n        return httpHeader;\n    }\n\n    private String getRequestId() {\n        return (UuidUtils.getUUID() + \"|\" + System.currentTimeMillis()).toUpperCase();\n    }\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","sourceCodeStart":156,"sourceCodeEnd":179,"githubUrl":"https://github.com/justauth/JustAuth/blob/694bbf1b010d93404e3bfb4824d90e9ddfaebebb/src/main/java/me/zhyd/oauth/request/AuthElemeRequest.java#L156-L179","documentation":"AuthElemeRequest.checkResponse() runs on token-endpoint responses: any 'error' key in the JSON causes AuthException with the 'error_description' text (standard OAuth2 error envelope). This fires while exchanging the authorization code or refreshing the token.","triggerScenarios":"getAccessToken()/refresh() when Eleme rejects the OAuth2 request: wrong client_id/client_secret, mismatched redirect_uri, or an already-consumed authorization code - Eleme answers {\"error\":\"...\",\"error_description\":\"...\"}.","commonSituations":"Redirect URI registered in the Eleme console differs (trailing slash, http vs https) from AuthConfig.redirectUri; credentials rotated in the console; double exchange of the code after a callback retry.","solutions":["Compare AuthConfig.redirectUri with the console-registered callback character by character (scheme, host, path, trailing slash).","Confirm client_id/client_secret are current for the Eleme app.","Consume each authorization code once - persist the state parameter and reject duplicate callbacks.","Inspect error_description in the AuthException: OAuth2 wording like 'invalid_grant' or 'invalid_client' maps directly to secret vs code problems."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Compare redirect URIs before starting the flow\npublic void verifyElemeRedirect(String configured, String registered) {\n    if (!Objects.equals(normalize(configured), normalize(registered))) {\n        throw new IllegalStateException(\"Eleme redirect_uri mismatch: \" + configured + \" vs \" + registered);\n    }\n}\nprivate String normalize(String u) { return u == null ? null : u.replaceAll(\"/$\", \"\"); }","typeGuard":null,"tryCatchPattern":"try {\n    return elemeRequest.getAccessToken(callback);\n} catch (AuthException e) {\n    log.warn(\"Eleme token error: {}\", e.getErrorMsg()); // OAuth2 error_description text\n    if (e.getErrorMsg() != null && e.getErrorMsg().contains(\"client\")) {\n        throw new ConfigurationException(\"Eleme client credentials rejected\", e);\n    }\n    throw e;\n}","preventionTips":["Register the exact redirect URI (scheme, host, path, trailing slash) in the Eleme console and reuse it verbatim in AuthConfig.","Treat 'invalid_client' as a config incident: alert and stop retrying until secrets are fixed.","Deduplicate callback processing by state so a code is never exchanged twice."],"tags":["oauth","eleme","justauth","token-exchange","redirect-uri"],"backgroundTag":null,"analyzedSha":"694bbf1b010d93404e3bfb4824d90e9ddfaebebb","analyzedAt":"2026-08-14T15:16:59.945Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}