Skip to content

Commit

Permalink
#568 修复三方平台多次授权时,RefreshToken 没有刷新的问题
Browse files Browse the repository at this point in the history
* fix 多次授权时,RefreshToken 没有刷新

* null 判断
  • Loading branch information
007gzs authored and binarywang committed May 2, 2018
1 parent 04ec788 commit 9ff53a5
Showing 1 changed file with 13 additions and 9 deletions.
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,19 @@ 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);
if (queryAuth == null || queryAuth.getAuthorizationInfo() == null) {
return queryAuth;
}
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

0 comments on commit 9ff53a5

Please sign in to comment.