{"record":{"id":"1ce672edceb7dfea","repo":"justauth/JustAuth","slug":"errmsg-1ce672","errorCode":null,"errorMessage":"${errMsg}","messagePattern":"\\$\\{errMsg\\}","errorType":"exception","errorClass":"AuthException","httpStatus":null,"severity":"error","filePath":"src/main/java/me/zhyd/oauth/request/AuthAlipayCertRequest.java","lineNumber":113,"sourceCode":"            .code(AuthResponseStatus.SUCCESS.getCode())\n            .data(AuthToken.builder()\n                .accessToken(response.getAccessToken())\n                .uid(response.getUserId())\n                .expireIn(Integer.parseInt(response.getExpiresIn()))\n                .refreshToken(response.getRefreshToken())\n                .build())\n            .build();\n    }\n\n    @Override\n    public AuthUser getUserInfo(AuthToken authToken) {\n        String accessToken = authToken.getAccessToken();\n        AlipayUserInfoShareRequest request = new AlipayUserInfoShareRequest();\n        AlipayUserInfoShareResponse response = null;\n        try {\n            response = this.alipayClient.certificateExecute(request, accessToken);\n        } catch (AlipayApiException e) {\n            throw new AuthException(e.getErrMsg(), e);\n        }\n        if (!response.isSuccess()) {\n            throw new AuthException(response.getSubMsg());\n        }\n\n        String province = response.getProvince(), city = response.getCity();\n        String location = String.format(\"%s %s\", StringUtils.isEmpty(province) ? \"\" : province, StringUtils.isEmpty(city) ? \"\" : city);\n\n        return AuthUser.builder()\n            .rawUserInfo(JSONObject.parseObject(JSONObject.toJSONString(response)))\n            .uuid(response.getOpenId())\n            .username(StringUtils.isEmpty(response.getUserName()) ? response.getNickName() : response.getUserName())\n            .nickname(response.getNickName())\n            .avatar(response.getAvatar())\n            .location(location)\n            .gender(AuthUserGender.getRealGender(response.getGender()))\n            .token(authToken)\n            .source(source.toString())","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/justauth/JustAuth/blob/694bbf1b010d93404e3bfb4824d90e9ddfaebebb/src/main/java/me/zhyd/oauth/request/AuthAlipayCertRequest.java#L95-L131","documentation":"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).","triggerScenarios":"AuthAlipayCertRequest.getUserInfo(authToken) where certificateExecute(request, accessToken) throws: expired or malformed access token, cert/public-key mismatch causing signature errors, gateway connectivity problems.","commonSituations":"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.","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"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if (authToken == null || StringUtils.isEmpty(authToken.getAccessToken())) {\n    throw new IllegalStateException(\"access token missing; authorize first\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    AuthUser user = alipayCertRequest.getUserInfo(token);\n} catch (AuthException e) {\n    log.warn(\"alipay cert getUserInfo transport failure: {}\", e.getMessage());\n    Throwable cause = e.getCause(); // original AlipayApiException with errCode\n    if (isTokenRelated(cause)) { token = alipayCertRequest.refresh(token).getData(); retry once; }\n    else throw e;\n}","preventionTips":["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"],"tags":["alipay","oauth","access-token","certificate-mode"],"backgroundTag":null,"analyzedSha":"694bbf1b010d93404e3bfb4824d90e9ddfaebebb","analyzedAt":"2026-08-14T15:16:59.945Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}