justauth/JustAuth · error · AuthException

object.getString("error_description")

Error message

object.getString("error_description")

What it means

AuthProginnRequest.checkResponse throws AuthException with 'error_description' when the Proginn (程序员客栈) API response contains an 'error' key — the standard OAuth2 error envelope for rejected grants or invalid tokens.

Source

Thrown at src/main/java/me/zhyd/oauth/request/AuthProginnRequest.java:81

            .uuid(object.getString("uid"))
            .username(object.getString("nickname"))
            .nickname(object.getString("nickname"))
            .avatar(object.getString("avatar"))
            .email(object.getString("email"))
            .gender(AuthUserGender.UNKNOWN)
            .token(authToken)
            .source(source.toString())
            .build();
    }

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

    /**
     * 返回带{@code state}参数的授权url,授权回调时会带上这个{@code state}
     *
     * @param state state 验证授权流程的参数,可以防止csrf
     * @return 返回授权地址
     */
    @Override
    public String authorize(String state) {
        return UrlBuilder.fromBaseUrl(super.authorize(state))
            .queryParam("scope", this.getScopes(" ", true, AuthScopeUtils.getDefaultScopes(AuthProginnScope.values())))
            .build();
    }
}

View on GitHub (pinned to 694bbf1b01)

Solutions

  1. Read error_description from the caught AuthException for the exact reason
  2. Guard the callback endpoint against double invocation (idempotent code exchange)
  3. Verify clientId/clientSecret/redirectUri against Proginn's developer console
  4. Restart the authorization flow for a fresh code

Example fix

null
Defensive patterns

Strategy: try-catch

Validate before calling

null

Type guard

null

Try / catch

try {
    proginnRequest.getAuthResponse(callback);
} catch (AuthException e) {
    log.warn("Proginn error: {}", e.getMessage());
    return redirectToLoginWithError("proginn");
}

Prevention

When it happens

Trigger: Token exchange or userinfo calls when Proginn returns an error body: wrong client credentials, expired/used code, or unapproved app permissions.

Common situations: Misconfigured AuthConfig credentials, redirect URI not whitelisted on Proginn's open platform, or reusing a code after a double callback (browser prefetch hitting the callback URL twice).

Related errors


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