justauth/JustAuth · error · AuthException

object.getString("error_description")

Error message

object.getString("error_description")

What it means

AuthOschinaRequest.checkResponse throws AuthException with 'error_description' when the OSChina (开源中国) API response contains an 'error' key. OSChina returns OAuth-style errors for invalid tokens or failed grants.

Source

Thrown at src/main/java/me/zhyd/oauth/request/AuthOschinaRequest.java:102

     * @param authToken 用户授权后的token
     * @return 返回获取userInfo的url
     */
    @Override
    protected String userInfoUrl(AuthToken authToken) {
        return UrlBuilder.fromBaseUrl(source.userInfo())
            .queryParam("access_token", authToken.getAccessToken())
            .queryParam("dataType", "json")
            .build();
    }

    /**
     * 检查响应内容是否正确
     *
     * @param object 请求响应内容
     */
    private void checkResponse(JSONObject object) {
        if (object.containsKey("error")) {
            throw new AuthException(object.getString("error_description"));
        }
    }
}

View on GitHub (pinned to 694bbf1b01)

Solutions

  1. Log error_description to see OSChina's stated reason
  2. Verify clientId/clientSecret are still valid on OSChina's open platform
  3. Start a fresh authorization round-trip for a new code
  4. If OSChina has deprecated the API for your app, remove the source from your login options

Example fix

null
Defensive patterns

Strategy: try-catch

Validate before calling

null

Type guard

null

Try / catch

try {
    oschinaRequest.getAuthResponse(callback);
} catch (AuthException e) {
    log.warn("OSChina error: {}", e.getMessage());
    // treat as provider outage; offer other login providers
}

Prevention

When it happens

Trigger: getAccessToken, refresh, or getUserInfo on AuthOschinaRequest when OSChina responds with {"error":...,"error_description":...} — wrong client secret, invalid/expired authorization code, or a revoked access token.

Common situations: Note OSChina has deprecated/limited its OAuth service in recent years; developers hit this when the API endpoint is offline or the app registration is no longer active.

Related errors


AI-assisted analysis of justauth/JustAuth@694bbf1b01 (2026-08-14). Data as JSON: /api/errors/0ac583025b9c78a7. Report an issue: GitHub.