justauth/JustAuth · error · AuthException

object.getJSONObject("error_response").getString("zh_desc")

Error message

object.getJSONObject("error_response").getString("zh_desc")

What it means

AuthJdRequest.checkResponse throws when the JD (Jingdong) open-platform response contains 'error_response', the envelope JD SDKs use for business errors. The message is the nested 'zh_desc' (Chinese description) field. It fires on both token exchange and user-info calls.

Source

Thrown at src/main/java/me/zhyd/oauth/request/AuthJdRequest.java:131

        JSONObject object = JSONObject.parseObject(response);

        this.checkResponse(object);

        return AuthResponse.<AuthToken>builder()
            .code(AuthResponseStatus.SUCCESS.getCode())
            .data(AuthToken.builder()
                .accessToken(object.getString("access_token"))
                .expireIn(object.getIntValue("expires_in"))
                .refreshToken(object.getString("refresh_token"))
                .scope(object.getString("scope"))
                .openId(object.getString("open_id"))
                .build())
            .build();
    }

    private void checkResponse(JSONObject object) {
        if (object.containsKey("error_response")) {
            throw new AuthException(object.getJSONObject("error_response").getString("zh_desc"));
        }
    }

    @Override
    public String authorize(String state) {
        return UrlBuilder.fromBaseUrl(source.authorize())
            .queryParam("app_key", config.getClientId())
            .queryParam("response_type", "code")
            .queryParam("redirect_uri", config.getRedirectUri())
            .queryParam("scope", this.getScopes(" ", true, AuthScopeUtils.getDefaultScopes(AuthJdScope.values())))
            .queryParam("state", getRealState(state))
            .build();
    }

}

View on GitHub (pinned to 694bbf1b01)

Solutions

  1. Decode the zh_desc message (it states the exact JD error, e.g. invalid access token)
  2. Refresh or re-acquire the access token if zh_desc mentions token expiry
  3. Confirm the JD open-platform app status is approved and the OAuth scope is bound
  4. Ensure config uses the correct unionId/endpoints for the JD environment you target

Example fix

null
Defensive patterns

Strategy: try-catch

Validate before calling

null

Type guard

null

Try / catch

try {
    jdRequest.getAuthResponse(callback);
} catch (AuthException e) {
    log.warn("JD error: {}", e.getMessage()); // zh_desc from error_response
    throw new AuthenticationServiceException("JD login failed", e);
}

Prevention

When it happens

Trigger: Calling AuthJdRequest.getAccessToken or getUserInfo when JD returns {"error_response":{"code":...,"zh_desc":"..."}} — typical for invalid access token, expired code, or ISV permission not granted.

Common situations: Sandbox vs production endpoint confusion, app not yet published/approved on the JD open platform, access token past its 24h validity, or the 'sn' (site) parameter mismatch.

Related errors


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