justauth/JustAuth · error · AuthException
${errMsg}
Error message
${errMsg} What it means
Wraps an AlipayApiException raised by alipayClient.execute(request, accessToken) while fetching the user profile (AlipayUserInfoShareRequest) in public-key mode. Message is e.getErrMsg(); the original exception is chained as the cause.
Source
Thrown at src/main/java/me/zhyd/oauth/request/AuthAlipayRequest.java:210
.code(AuthResponseStatus.SUCCESS.getCode())
.data(AuthToken.builder()
.accessToken(response.getAccessToken())
.uid(response.getUserId())
.expireIn(Integer.parseInt(response.getExpiresIn()))
.refreshToken(response.getRefreshToken())
.build())
.build();
}
@Override
public AuthUser getUserInfo(AuthToken authToken) {
String accessToken = authToken.getAccessToken();
AlipayUserInfoShareRequest request = new AlipayUserInfoShareRequest();
AlipayUserInfoShareResponse response = null;
try {
response = this.alipayClient.execute(request, accessToken);
} catch (AlipayApiException e) {
throw new AuthException(e.getErrMsg(), e);
}
if (!response.isSuccess()) {
throw new AuthException(response.getSubMsg());
}
String province = response.getProvince(), city = response.getCity();
String location = String.format("%s %s", StringUtils.isEmpty(province) ? "" : province, StringUtils.isEmpty(city) ? "" : city);
return AuthUser.builder()
.rawUserInfo(JSONObject.parseObject(JSONObject.toJSONString(response)))
.uuid(response.getUserId())
.username(StringUtils.isEmpty(response.getUserName()) ? response.getNickName() : response.getUserName())
.nickname(response.getNickName())
.avatar(response.getAvatar())
.location(location)
.gender(AuthUserGender.getRealGender(response.getGender()))
.token(authToken)
.source(source.toString())View on GitHub (pinned to 694bbf1b01)
Solutions
- Check the AlipayApiException cause's errCode — isv.invalid-signature points to a key mismatch, HTTP errors point to network
- Re-copy the Alipay open-platform public key into AuthConfig if keys were regenerated
- Verify the access token is complete and was obtained from the same environment (sandbox vs prod)
Defensive patterns
Strategy: try-catch
Validate before calling
if (StringUtils.isEmpty(authToken.getAccessToken())) {
throw new IllegalStateException("access token required for alipay getUserInfo");
} Try / catch
try {
return alipayRequest.getUserInfo(token);
} catch (AuthException e) {
if (e.getCause() instanceof AlipayApiException) {
String errCode = ((AlipayApiException) e.getCause()).getErrCode();
log.warn("alipay userinfo api error {}", errCode);
}
throw e;
} Prevention
- Keep alipayPublicKey synced with open-platform key rotations
- Fetch user info right after token acquisition
- Distinguish AlipayApiException (transport/sign) from business failure (error 31) in handling
When it happens
Trigger: AuthAlipayRequest.getUserInfo where execute throws AlipayApiException: signature verification of the gateway response fails, the access token is malformed at the protocol level, or a network error occurs.
Common situations: Wrong alipayPublicKey (most common — sign/verify mismatch after key rotation); access token truncated or empty; firewall blocking api.alipay.com from the server.
Related errors
AI-assisted analysis of justauth/JustAuth@694bbf1b01 (2026-08-14).
Data as JSON: /api/errors/d6298722df85324e.
Report an issue: GitHub.