Skip to content

Commit 9ff53a5

Browse files
007gzsbinarywang
authored andcommitted
#568 修复三方平台多次授权时,RefreshToken 没有刷新的问题
* fix 多次授权时,RefreshToken 没有刷新 * null 判断
1 parent 04ec788 commit 9ff53a5

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenComponentServiceImpl.java

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -193,14 +193,6 @@ public String route(final WxOpenXmlMessage wxMessage) throws WxErrorException {
193193
if (queryAuth == null || queryAuth.getAuthorizationInfo() == null || queryAuth.getAuthorizationInfo().getAuthorizerAppid() == null) {
194194
throw new NullPointerException("getQueryAuth");
195195
}
196-
WxOpenAuthorizationInfo authorizationInfo = queryAuth.getAuthorizationInfo();
197-
if (authorizationInfo.getAuthorizerAccessToken() != null) {
198-
getWxOpenConfigStorage().updateAuthorizerAccessToken(authorizationInfo.getAuthorizerAppid(),
199-
authorizationInfo.getAuthorizerAccessToken(), authorizationInfo.getExpiresIn());
200-
}
201-
if (authorizationInfo.getAuthorizerRefreshToken() != null) {
202-
getWxOpenConfigStorage().setAuthorizerRefreshToken(authorizationInfo.getAuthorizerAppid(), authorizationInfo.getAuthorizerRefreshToken());
203-
}
204196
return "success";
205197
}
206198
return "";
@@ -212,7 +204,19 @@ public WxOpenQueryAuthResult getQueryAuth(String authorizationCode) throws WxErr
212204
jsonObject.addProperty("component_appid", getWxOpenConfigStorage().getComponentAppId());
213205
jsonObject.addProperty("authorization_code", authorizationCode);
214206
String responseContent = post(API_QUERY_AUTH_URL, jsonObject.toString());
215-
return WxOpenGsonBuilder.create().fromJson(responseContent, WxOpenQueryAuthResult.class);
207+
WxOpenQueryAuthResult queryAuth = WxOpenGsonBuilder.create().fromJson(responseContent, WxOpenQueryAuthResult.class);
208+
if (queryAuth == null || queryAuth.getAuthorizationInfo() == null) {
209+
return queryAuth;
210+
}
211+
WxOpenAuthorizationInfo authorizationInfo = queryAuth.getAuthorizationInfo();
212+
if (authorizationInfo.getAuthorizerAccessToken() != null) {
213+
getWxOpenConfigStorage().updateAuthorizerAccessToken(authorizationInfo.getAuthorizerAppid(),
214+
authorizationInfo.getAuthorizerAccessToken(), authorizationInfo.getExpiresIn());
215+
}
216+
if (authorizationInfo.getAuthorizerRefreshToken() != null) {
217+
getWxOpenConfigStorage().setAuthorizerRefreshToken(authorizationInfo.getAuthorizerAppid(), authorizationInfo.getAuthorizerRefreshToken());
218+
}
219+
return queryAuth;
216220
}
217221

218222
@Override

0 commit comments

Comments
 (0)