justauth/JustAuth · error · AuthException

object.getString("m")

Error message

object.getString("m")

What it means

Same {c,m,d} envelope check applied in AuthKujialeRequest.getUserInfo: if the user-info response code 'c' is not "0", JustAuth throws AuthException carrying the 'm' message. Unlike the token path, this fires while fetching the user profile with a supposedly valid token.

Source

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

    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()
            .rawUserInfo(resultObject)
            .username(resultObject.getString("userName"))
            .nickname(resultObject.getString("userName"))
            .avatar(resultObject.getString("avatar"))
            .uuid(resultObject.getString("openId"))
            .token(authToken)
            .source(source.toString())
            .build();
    }

    /**
     * 获取酷家乐的openId,此id在当前client范围内可以唯一识别授权用户
     *
     * @param authToken 通过{@link AuthKujialeRequest#getAccessToken(AuthCallback)}获取到的{@code authToken}

View on GitHub (pinned to 694bbf1b01)

Solutions

  1. If 'm' indicates token expiry, call refresh (or re-authorize) before getUserInfo
  2. Ensure the openId passed comes from the same authorization as the access token
  3. Persist expiresIn and proactively refresh tokens before calling user info
  4. Log and surface the Kujiale message for diagnosis

Example fix

null
Defensive patterns

Strategy: retry

Validate before calling

long expiresAt = tokenStore.getIssuedAt() + token.getExpiresIn() * 1000L;
if (System.currentTimeMillis() > expiresAt - 60_000L) {
    token = kujialeRequest.refresh(token).getData(); // refresh before it expires
}

Type guard

null

Try / catch

try {
    return kujialeRequest.getUserInfo(token);
} catch (AuthException e) {
    token = kujialeRequest.refresh(token).getData();
    return kujialeRequest.getUserInfo(token); // one retry with fresh token
}

Prevention

When it happens

Trigger: Calling getUserInfo(authToken) when Kujiale rejects the access_token (expired or revoked), or when the open_id query param does not match the token.

Common situations: Token stored and reused past its expiresIn, revoked app authorization, or openId fetched from a different token/session.

Related errors


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