{"record":{"id":"5ad348a67fcf515e","repo":"justauth/JustAuth","slug":"object-getjsonobject-error-getstring-message","errorCode":null,"errorMessage":"object.getJSONObject(\"error\").getString(\"message\")","messagePattern":"object\\.getJSONObject\\(\"error\"\\)\\.getString\\(\"message\"\\)","errorType":"exception","errorClass":"AuthException","httpStatus":null,"severity":"error","filePath":"src/main/java/me/zhyd/oauth/request/AuthElemeRequest.java","lineNumber":103,"sourceCode":"        paramsMap.put(\"nop\", \"1.0.0\");\n        paramsMap.put(\"id\", requestId);\n        paramsMap.put(\"action\", action);\n        paramsMap.put(\"token\", authToken.getAccessToken());\n        paramsMap.put(\"metas\", metasHashMap);\n        paramsMap.put(\"params\", parameters);\n        paramsMap.put(\"signature\", signature);\n\n        HttpHeader httpHeader = this.buildHeader(CONTENT_TYPE_JSON, requestId, false);\n        String response = new HttpUtils(config.getHttpConfig()).post(source.userInfo(), JSONObject.toJSONString(paramsMap), httpHeader).getBody();\n\n        JSONObject object = JSONObject.parseObject(response);\n\n        // 校验请求\n        if (object.containsKey(\"name\")) {\n            throw new AuthException(object.getString(\"message\"));\n        }\n        if (object.containsKey(\"error\") && null != object.get(\"error\")) {\n            throw new AuthException(object.getJSONObject(\"error\").getString(\"message\"));\n        }\n\n        JSONObject result = object.getJSONObject(\"result\");\n\n        return AuthUser.builder()\n            .rawUserInfo(result)\n            .uuid(result.getString(\"userId\"))\n            .username(result.getString(\"userName\"))\n            .nickname(result.getString(\"userName\"))\n            .gender(AuthUserGender.UNKNOWN)\n            .token(authToken)\n            .source(source.toString())\n            .build();\n    }\n\n    @Override\n    public AuthResponse<AuthToken> refresh(AuthToken oldToken) {\n        Map<String, String> form = new HashMap<>(4);","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/justauth/JustAuth/blob/694bbf1b010d93404e3bfb4824d90e9ddfaebebb/src/main/java/me/zhyd/oauth/request/AuthElemeRequest.java#L85-L121","documentation":"The second guard in AuthElemeRequest.getUserInfo(): when the response has a non-null 'error' object, JustAuth throws AuthException with error.message - the standard Eleme RPC error shape {\"error\":{\"message\":..,\"type\":..}}. This covers API-level rejections such as invalid token or insufficient scope returned after the RPC call completes.","triggerScenarios":"getUserInfo() with an access token that Eleme has expired or revoked, or when the app lacks permission for the requested API - Eleme wraps the failure in an 'error' object and this branch surfaces its message.","commonSituations":"Long-lived sessions where the 30-day Eleme token lapsed without refresh; user deauthorized the app in Eleme; or the app's API quota was exceeded and Eleme returns an error object with a quota message.","solutions":["Use the stored refreshToken to call refresh() and retry getUserInfo() with the new token.","Prompt re-authorization when refresh also fails - the user may have removed the app.","Check the error 'message' text: 'invalid token' means expiry; permission-related text means the app scope needs approval in the console.","Keep HTTP logging on in staging to correlate error.message values with Eleme's error-code documentation."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    return elemeRequest.getUserInfo(token);\n} catch (AuthException e) {\n    if (e.getErrorMsg() != null && e.getErrorMsg().contains(\"token\")) {\n        try {\n            AuthResponse refreshed = elemeRequest.refresh(AuthToken.builder().refreshToken(refreshToken).build());\n            return elemeRequest.getUserInfo(refreshed.getData());\n        } catch (AuthException retry) {\n            return redirectToReauthorize();\n        }\n    }\n    throw e;\n}","preventionTips":["Persist refresh tokens and refresh proactively before the 30-day Eleme token expires.","Handle the deauthorization path: if refresh also fails, clear local session and re-authorize.","Watch for quota error messages and alert before hitting Eleme rate limits."],"tags":["oauth","eleme","justauth","api-error","token-expired"],"backgroundTag":null,"analyzedSha":"694bbf1b010d93404e3bfb4824d90e9ddfaebebb","analyzedAt":"2026-08-14T15:16:59.945Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}