justauth/JustAuth · error · AuthException

accessTokenObject.getString("m")

Error message

accessTokenObject.getString("m")

What it means

AuthKujialeRequest.checkResponse throws AuthException with the 'm' (message) field when the Kujiale token response's 'c' (code) field is not "0". Kujiale wraps all responses as {c: code, m: message, d: data}; any non-zero code is a failure.

Source

Thrown at src/main/java/me/zhyd/oauth/request/AuthKujialeRequest.java:68

    public AuthToken getAccessToken(AuthCallback authCallback) {
        String response = doPostAuthorizationCode(authCallback.getCode());
        return getAuthToken(response);
    }

    private AuthToken getAuthToken(String response) {
        JSONObject accessTokenObject = checkResponse(response);
        JSONObject resultObject = accessTokenObject.getJSONObject("d");
        return AuthToken.builder()
            .accessToken(resultObject.getString("accessToken"))
            .refreshToken(resultObject.getString("refreshToken"))
            .expireIn(resultObject.getIntValue("expiresIn"))
            .build();
    }

    private JSONObject checkResponse(String response) {
        JSONObject accessTokenObject = JSONObject.parseObject(response);
        if (!"0".equals(accessTokenObject.getString("c"))) {
            throw new AuthException(accessTokenObject.getString("m"));
        }
        return accessTokenObject;
    }

    @Override
    public AuthUser getUserInfo(AuthToken authToken) {
        String openId = this.getOpenId(authToken);
        String response = new HttpUtils(config.getHttpConfig()).get(UrlBuilder.fromBaseUrl(source.userInfo())
            .queryParam("access_token", authToken.getAccessToken())
            .queryParam("open_id", openId)
            .build()).getBody();
        JSONObject object = JSONObject.parseObject(response);
        if (!"0".equals(object.getString("c"))) {
            throw new AuthException(object.getString("m"));
        }
        JSONObject resultObject = object.getJSONObject("d");

        return AuthUser.builder()

View on GitHub (pinned to 694bbf1b01)

Solutions

  1. Log the 'm' message from the AuthException — Kujiale states the reason in Chinese
  2. Verify appKey/appSecret in AuthConfig match the Kujiale open-platform app
  3. Regenerate the authorization flow from scratch (fresh code) instead of replaying an old callback
  4. Confirm the redirect URI is whitelisted in the Kujiale console

Example fix

null
Defensive patterns

Strategy: try-catch

Validate before calling

null

Type guard

null

Try / catch

try {
    AuthToken t = kujialeRequest.getAccessToken(callback);
} catch (AuthException e) {
    // e.getMessage() is Kujiale's 'm' field
    log.warn("Kujiale token error: {}", e.getMessage());
}

Prevention

When it happens

Trigger: AuthKujialeRequest.getAccessToken when Kujiale's /oauth2/token/token endpoint returns a non-zero 'c', e.g. wrong app_key/app_secret, invalid grant code, or unauthorized scope.

Common situations: Credentials from the wrong Kujiale environment (test vs production), expired authorization code, or the developer account lacking API access.

Related errors


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