Skip to content

fix 三方平台多次授权时,RefreshToken 没有刷新 #568

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 2, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix 多次授权时,RefreshToken 没有刷新
  • Loading branch information
007gzs committed May 2, 2018
commit ae436e5e2a1c7ee6ed85a9b63116e29972237934
Original file line number Diff line number Diff line change
Expand Up @@ -193,14 +193,6 @@ public String route(final WxOpenXmlMessage wxMessage) throws WxErrorException {
if (queryAuth == null || queryAuth.getAuthorizationInfo() == null || queryAuth.getAuthorizationInfo().getAuthorizerAppid() == null) {
throw new NullPointerException("getQueryAuth");
}
WxOpenAuthorizationInfo authorizationInfo = queryAuth.getAuthorizationInfo();
if (authorizationInfo.getAuthorizerAccessToken() != null) {
getWxOpenConfigStorage().updateAuthorizerAccessToken(authorizationInfo.getAuthorizerAppid(),
authorizationInfo.getAuthorizerAccessToken(), authorizationInfo.getExpiresIn());
}
if (authorizationInfo.getAuthorizerRefreshToken() != null) {
getWxOpenConfigStorage().setAuthorizerRefreshToken(authorizationInfo.getAuthorizerAppid(), authorizationInfo.getAuthorizerRefreshToken());
}
return "success";
}
return "";
Expand All @@ -212,7 +204,17 @@ public WxOpenQueryAuthResult getQueryAuth(String authorizationCode) throws WxErr
jsonObject.addProperty("component_appid", getWxOpenConfigStorage().getComponentAppId());
jsonObject.addProperty("authorization_code", authorizationCode);
String responseContent = post(API_QUERY_AUTH_URL, jsonObject.toString());
return WxOpenGsonBuilder.create().fromJson(responseContent, WxOpenQueryAuthResult.class);
WxOpenQueryAuthResult queryAuth = WxOpenGsonBuilder.create().fromJson(responseContent, WxOpenQueryAuthResult.class);

WxOpenAuthorizationInfo authorizationInfo = queryAuth.getAuthorizationInfo();
if (authorizationInfo.getAuthorizerAccessToken() != null) {
getWxOpenConfigStorage().updateAuthorizerAccessToken(authorizationInfo.getAuthorizerAppid(),
authorizationInfo.getAuthorizerAccessToken(), authorizationInfo.getExpiresIn());
}
if (authorizationInfo.getAuthorizerRefreshToken() != null) {
getWxOpenConfigStorage().setAuthorizerRefreshToken(authorizationInfo.getAuthorizerAppid(), authorizationInfo.getAuthorizerRefreshToken());
}
return queryAuth;
}

@Override
Expand Down