justauth/JustAuth · error · AuthException
${errMsg}
Error message
${errMsg} What it means
Wraps an AlipayApiException raised while executing AlipayUserInfoShareRequest in certificate mode during getUserInfo. The message is e.getErrMsg(); typical causes are signature verification failure, network/protocol errors, or an invalid access token at the transport layer (a business-level rejection instead surfaces as error 22).
Source
Thrown at src/main/java/me/zhyd/oauth/request/AuthAlipayCertRequest.java:113
.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.certificateExecute(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.getOpenId())
.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
- Refresh the access token first (refresh()) before calling getUserInfo if it may be older than the token lifetime
- Verify the certificate-mode credentials (app cert, alipay public key cert, root cert) match the app that issued the token
- Inspect the full AlipayApiException (cause is chained as `e`) for errCode such as isv.invalid-signature or a4044
- Check network/proxy reachability to the Alipay gateway
Defensive patterns
Strategy: try-catch
Validate before calling
if (authToken == null || StringUtils.isEmpty(authToken.getAccessToken())) {
throw new IllegalStateException("access token missing; authorize first");
} Try / catch
try {
AuthUser user = alipayCertRequest.getUserInfo(token);
} catch (AuthException e) {
log.warn("alipay cert getUserInfo transport failure: {}", e.getMessage());
Throwable cause = e.getCause(); // original AlipayApiException with errCode
if (isTokenRelated(cause)) { token = alipayCertRequest.refresh(token).getData(); retry once; }
else throw e;
} Prevention
- Call getUserInfo immediately after getAccessToken while the token is fresh
- Log the chained AlipayApiException errCode for signature vs token vs network diagnosis
- Keep certificate bundles in sync with app credential rotations
When it happens
Trigger: AuthAlipayCertRequest.getUserInfo(authToken) where certificateExecute(request, accessToken) throws: expired or malformed access token, cert/public-key mismatch causing signature errors, gateway connectivity problems.
Common situations: Access token already expired (default ~2h for Alipay) before getUserInfo is called; cert files rotated but the JustAuth config still holds old ones; network egress blocked to openapi.alipay.com.
Related errors
AI-assisted analysis of justauth/JustAuth@694bbf1b01 (2026-08-14).
Data as JSON: /api/errors/1ce672edceb7dfea.
Report an issue: GitHub.