justauth/JustAuth · error · AuthException

object.getString("message")

Error message

object.getString("message")

What it means

In AuthElemeRequest.getUserInfo(), if the response JSON contains a top-level 'name' key (Eleme's error envelope includes name+message), JustAuth throws AuthException with the 'message' field. Caveat: the guard checks 'name' but reads 'message', so if the payload has name without message the thrown text is null - capture the raw response in that case.

Source

Thrown at src/main/java/me/zhyd/oauth/request/AuthElemeRequest.java:100

        String requestId = this.getRequestId();

        Map<String, Object> paramsMap = new HashMap<>();
        paramsMap.put("nop", "1.0.0");
        paramsMap.put("id", requestId);
        paramsMap.put("action", action);
        paramsMap.put("token", authToken.getAccessToken());
        paramsMap.put("metas", metasHashMap);
        paramsMap.put("params", parameters);
        paramsMap.put("signature", signature);

        HttpHeader httpHeader = this.buildHeader(CONTENT_TYPE_JSON, requestId, false);
        String response = new HttpUtils(config.getHttpConfig()).post(source.userInfo(), JSONObject.toJSONString(paramsMap), httpHeader).getBody();

        JSONObject object = JSONObject.parseObject(response);

        // 校验请求
        if (object.containsKey("name")) {
            throw new AuthException(object.getString("message"));
        }
        if (object.containsKey("error") && null != object.get("error")) {
            throw new AuthException(object.getJSONObject("error").getString("message"));
        }

        JSONObject result = object.getJSONObject("result");

        return AuthUser.builder()
            .rawUserInfo(result)
            .uuid(result.getString("userId"))
            .username(result.getString("userName"))
            .nickname(result.getString("userName"))
            .gender(AuthUserGender.UNKNOWN)
            .token(authToken)
            .source(source.toString())
            .build();
    }

View on GitHub (pinned to 694bbf1b01)

Solutions

  1. Check the Eleme open platform console that your app has the user-info API permission approved.
  2. If the thrown message is null, log the HTTP response body directly to see the full error envelope (it contains name + message).
  3. Verify server clock sync (NTP) - Eleme signatures include a timestamp and reject drift.
  4. Call refresh() if the access token is older than its 30-day validity before requesting user info.

Example fix

// before - message can be null when only 'name' is present
if (object.containsKey("name")) {
    throw new AuthException(object.getString("message"));
}

// after - always give the caller the actual payload
if (object.containsKey("name")) {
    String msg = object.getString("message");
    throw new AuthException(msg != null ? msg : object.toJSONString());
}
Defensive patterns

Strategy: try-catch

Try / catch

try {
    return elemeRequest.getUserInfo(token);
} catch (AuthException e) {
    // msg can be null when Eleme returns name without message
    String safe = e.getErrorMsg() != null ? e.getErrorMsg() : "Eleme user info failed";
    log.warn("Eleme error: {}", safe);
    return AuthResponse.builder().code(500).msg(safe).build();
}

Prevention

When it happens

Trigger: Calling getUserInfo() on AuthElemeRequest when the Eleme open-platform returns an error object: invalid/expired token, missing API permission for the user scope, or a signature/params mismatch in the RPC wrapper.

Common situations: Eleme app not yet granted the '获取用户信息' API permission, token expired between login and the userinfo call, or system clock skew breaking the signature (which Eleme reports as a named error object).

Related errors


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