@@ -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