Browse Source

#568 修复三方平台多次授权时,RefreshToken 没有刷新的问题

* fix 多次授权时,RefreshToken 没有刷新

* null 判断
master
007gzs 7 years ago
committed by Binary Wang
parent
commit
9ff53a59f9
1 changed files with 13 additions and 9 deletions
  1. +13
    -9
      weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenComponentServiceImpl.java

+ 13
- 9
weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenComponentServiceImpl.java View File

@@ -193,14 +193,6 @@ public class WxOpenComponentServiceImpl implements WxOpenComponentService {
if (queryAuth == null || queryAuth.getAuthorizationInfo() == null || queryAuth.getAuthorizationInfo().getAuthorizerAppid() == null) { if (queryAuth == null || queryAuth.getAuthorizationInfo() == null || queryAuth.getAuthorizationInfo().getAuthorizerAppid() == null) {
throw new NullPointerException("getQueryAuth"); 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 "success";
} }
return ""; return "";
@@ -212,7 +204,19 @@ public class WxOpenComponentServiceImpl implements WxOpenComponentService {
jsonObject.addProperty("component_appid", getWxOpenConfigStorage().getComponentAppId()); jsonObject.addProperty("component_appid", getWxOpenConfigStorage().getComponentAppId());
jsonObject.addProperty("authorization_code", authorizationCode); jsonObject.addProperty("authorization_code", authorizationCode);
String responseContent = post(API_QUERY_AUTH_URL, jsonObject.toString()); 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 @Override


Loading…
Cancel
Save