Skip to content

Commit 1e94c45

Browse files
committed
issue #104 WxCpService.oauth2getUserInfo方法不会去刷新access token
1 parent d2eb529 commit 1e94c45

File tree

1 file changed

+7
-16
lines changed

1 file changed

+7
-16
lines changed

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpServiceImpl.java

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -427,22 +427,13 @@ public String oauth2buildAuthorizationUrl(String state) {
427427

428428
@Override
429429
public String[] oauth2getUserInfo(String code) throws WxErrorException {
430-
String url = "https://qyapi.weixin.qq.com/cgi-bin/user/getuserinfo?";
431-
url += "access_token=" + wxCpConfigStorage.getAccessToken();
432-
url += "&code=" + code;
433-
url += "&agendid=" + wxCpConfigStorage.getAgentId();
434-
435-
try {
436-
RequestExecutor<String, String> executor = new SimpleGetRequestExecutor();
437-
String responseText = executor.execute(getHttpclient(), httpProxy, url, null);
438-
JsonElement je = Streams.parse(new JsonReader(new StringReader(responseText)));
439-
JsonObject jo = je.getAsJsonObject();
440-
return new String[] {GsonHelper.getString(jo, "UserId"), GsonHelper.getString(jo, "DeviceId")};
441-
} catch (ClientProtocolException e) {
442-
throw new RuntimeException(e);
443-
} catch (IOException e) {
444-
throw new RuntimeException(e);
445-
}
430+
String url = "https://qyapi.weixin.qq.com/cgi-bin/user/getuserinfo?"
431+
+ "code=" + code
432+
+ "&agendid=" + wxCpConfigStorage.getAgentId();
433+
String responseText = get(url, null);
434+
JsonElement je = Streams.parse(new JsonReader(new StringReader(responseText)));
435+
JsonObject jo = je.getAsJsonObject();
436+
return new String[] {GsonHelper.getString(jo, "UserId"), GsonHelper.getString(jo, "DeviceId")};
446437
}
447438

448439
@Override

0 commit comments

Comments
 (0)