@@ -193,14 +193,6 @@ public String route(final WxOpenXmlMessage wxMessage) throws WxErrorException {
193
193
if (queryAuth == null || queryAuth .getAuthorizationInfo () == null || queryAuth .getAuthorizationInfo ().getAuthorizerAppid () == null ) {
194
194
throw new NullPointerException ("getQueryAuth" );
195
195
}
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
- }
204
196
return "success" ;
205
197
}
206
198
return "" ;
@@ -212,7 +204,19 @@ public WxOpenQueryAuthResult getQueryAuth(String authorizationCode) throws WxErr
212
204
jsonObject .addProperty ("component_appid" , getWxOpenConfigStorage ().getComponentAppId ());
213
205
jsonObject .addProperty ("authorization_code" , authorizationCode );
214
206
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 ;
216
220
}
217
221
218
222
@ Override
0 commit comments