{"record":{"id":"5762fb31d0ffee42","repo":"justauth/JustAuth","slug":"failed-to-get-token-from-renren","errorCode":null,"errorMessage":"Failed to get token from Renren: ","messagePattern":"Failed to get token from Renren: ","errorType":"exception","errorClass":"AuthException","httpStatus":null,"severity":"error","filePath":"src/main/java/me/zhyd/oauth/request/AuthRenrenRequest.java","lineNumber":74,"sourceCode":"            .gender(getGender(userObj))\n            .token(authToken)\n            .source(source.toString())\n            .build();\n    }\n\n    @Override\n    public AuthResponse<AuthToken> refresh(AuthToken authToken) {\n        return AuthResponse.<AuthToken>builder()\n            .code(SUCCESS.getCode())\n            .data(getToken(this.refreshTokenUrl(authToken.getRefreshToken())))\n            .build();\n    }\n\n    private AuthToken getToken(String url) {\n        String response = new HttpUtils(config.getHttpConfig()).post(url).getBody();\n        JSONObject jsonObject = JSONObject.parseObject(response);\n        if (jsonObject.containsKey(\"error\")) {\n            throw new AuthException(\"Failed to get token from Renren: \" + jsonObject);\n        }\n\n        return AuthToken.builder()\n            .tokenType(jsonObject.getString(\"token_type\"))\n            .expireIn(jsonObject.getIntValue(\"expires_in\"))\n            .accessToken(UrlUtil.urlEncode(jsonObject.getString(\"access_token\")))\n            .refreshToken(UrlUtil.urlEncode(jsonObject.getString(\"refresh_token\")))\n            .openId(jsonObject.getJSONObject(\"user\").getString(\"id\"))\n            .build();\n    }\n\n    private String getAvatarUrl(JSONObject userObj) {\n        JSONArray jsonArray = userObj.getJSONArray(\"avatar\");\n        if (Objects.isNull(jsonArray) || jsonArray.isEmpty()) {\n            return null;\n        }\n        return jsonArray.getJSONObject(0).getString(\"url\");\n    }","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/justauth/JustAuth/blob/694bbf1b010d93404e3bfb4824d90e9ddfaebebb/src/main/java/me/zhyd/oauth/request/AuthRenrenRequest.java#L56-L92","documentation":"AuthRenrenRequest.getToken throws AuthException with message 'Failed to get token from Renren: ' + full JSON body when the Renren token/refresh response contains an 'error' key. Renren's OAuth2 returns an error object with code/description for failed grants.","triggerScenarios":"Calling getAccessToken or refresh when Renren rejects the grant: invalid authorization code, wrong client secret, or redirect_uri mismatch. The whole response JSON is embedded in the exception message.","commonSituations":"Renren's open platform has been largely deprecated; many developers hit this because the service or their registered app is no longer active, or credentials rotted. Also common: code exchanged twice due to double callback hits.","solutions":["Read the embedded JSON in the message — Renren's error object names the cause","Verify clientId/clientSecret/redirectUri against the Renren developer console (if still accessible)","Make the callback idempotent so the one-time code is not exchanged twice","If Renren has sunset the API for your app, retire the Renren login option"],"exampleFix":"null","handlingStrategy":"fallback","validationCode":"null","typeGuard":"null","tryCatchPattern":"try {\n    renrenRequest.getAuthResponse(callback);\n} catch (AuthException e) {\n    if (e.getMessage() != null && e.getMessage().startsWith(\"Failed to get token from Renren\")) {\n        // parse embedded JSON, and fall back to other login providers\n        log.warn(\"Renren OAuth unavailable: {}\", e.getMessage());\n        return fallbackToOtherProviders();\n    }\n    throw e;\n}","preventionTips":["Health-check Renren OAuth before exposing the login button (platform largely deprecated)","Parse the embedded JSON body for the underlying error object","Design the login page so a single dead IdP degrades gracefully"],"tags":["oauth","renren","deprecated-api","auth-exception"],"backgroundTag":null,"analyzedSha":"694bbf1b010d93404e3bfb4824d90e9ddfaebebb","analyzedAt":"2026-08-14T15:16:59.945Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}