justauth/JustAuth · error · AuthException
5005
5005
Error message
Unidentified platform
What it means
AbstractAuthWeChatEnterpriseRequest.getUserInfo calls the WeChat Work (企业微信) user-info endpoint and checks for the UserId key. If the response has no UserId, the authenticated user does not belong to the configured enterprise/corp (or is following via a different scope), and the library throws AuthException 5005 (Unidentified platform) with the source attached.
Source
Thrown at src/main/java/me/zhyd/oauth/request/AbstractAuthWeChatEnterpriseRequest.java:56
String response = doGetAuthorizationCode(accessTokenUrl(null));
JSONObject object = this.checkResponse(response);
return AuthToken.builder()
.accessToken(object.getString("access_token"))
.expireIn(object.getIntValue("expires_in"))
.code(authCallback.getCode())
.build();
}
@Override
public AuthUser getUserInfo(AuthToken authToken) {
String response = doGetUserInfo(authToken);
JSONObject object = this.checkResponse(response);
// 返回 OpenId 或其他,均代表非当前企业用户,不支持
if (!object.containsKey("UserId")) {
throw new AuthException(AuthResponseStatus.UNIDENTIFIED_PLATFORM, source);
}
String userId = object.getString("UserId");
String userTicket = object.getString("user_ticket");
JSONObject userDetail = getUserDetail(authToken.getAccessToken(), userId, userTicket);
return AuthUser.builder()
.rawUserInfo(userDetail)
.username(userDetail.getString("name"))
.nickname(userDetail.getString("alias"))
.avatar(userDetail.getString("avatar"))
.location(userDetail.getString("address"))
.email(userDetail.getString("email"))
.uuid(userId)
.gender(AuthUserGender.getWechatRealGender(userDetail.getString("gender")))
.token(authToken)
.source(source.toString())
.build();
}View on GitHub (pinned to 694bbf1b01)
Solutions
- Verify the user actually belongs to the corp: log in with a member of the enterprise tied to corpId/agentId in AuthConfig.
- Double-check corpId and agentId (and secret) all come from the same WeChat Work app; mismatched IDs produce OpenId-only responses.
- If you need public WeChat login (non-corp users), switch to the WECHAT_MOBILE or WECHAT_OPEN web sources instead of WECHAT_ENTERPRISE.
- Treat 5005 as a business signal: prompt 'please use your enterprise account' rather than a system error.
Example fix
// before
// public login page uses WECHAT_ENTERPRISE source; external users -> 5005
// after
try { return request.login(callback); }
catch (AuthException e) {
if (e.getErrcode() == AuthResponseStatus.UNIDENTIFIED_PLATFORM.getCode()) {
return Response.error("Please sign in with your enterprise WeChat account");
}
throw e;
} Defensive patterns
Strategy: try-catch
Try / catch
try { return request.login(callback); } catch (AuthException e) { if (e.getErrcode() == AuthResponseStatus.UNIDENTIFIED_PLATFORM.getCode()) { return respond("sign in with your enterprise WeChat account"); } throw e; } Prevention
- Use WECHAT_ENTERPRISE only for corp-member login; use public WeChat sources for consumer login.
- Verify corpId, agentId and secret all belong to the same self-built app.
- Treat 5005 as a business rule (non-member), not a system failure.
When it happens
Trigger: A WeChat user outside the corp scans the QR code (the API returns OpenId only, no UserId); wrong corpId/agentId in AuthConfig so membership lookup resolves to a different enterprise; using a self-built app token against users of another tenant.
Common situations: Public-facing login pages using the enterprise (WeChat Work) source by mistake — external users will never have UserId; copying agentId from one corp and corpId from another; testing with a personal WeChat account that has not joined the enterprise.
Related errors
AI-assisted analysis of justauth/JustAuth@694bbf1b01 (2026-08-14).
Data as JSON: /api/errors/ec0f1b56642f4dac.
Report an issue: GitHub.