提交 2dba2bae 编写于 作者: 不合群的混子's avatar 不合群的混子

🎨 去除重复代码

上级 2abca4f1
......@@ -30,12 +30,11 @@ public class AuthWeChatRequest extends BaseAuthRequest {
protected AuthToken getAccessToken(String code) {
String accessTokenUrl = UrlBuilder.getWeChatAccessTokenUrl(config.getClientId(), config.getClientSecret(), code);
HttpResponse response = HttpRequest.get(accessTokenUrl).execute();
JSONObject accessTokenObject = JSONObject.parseObject(response.body());
if (!accessTokenObject.containsKey("access_token") || !accessTokenObject.containsKey("openid") || !accessTokenObject
JSONObject object = JSONObject.parseObject(response.body());
if (!object.containsKey("access_token") || !object.containsKey("openid") || !object
.containsKey("refresh_token")) {
throw new AuthException("Unable to get access_token or openid or refresh_token from wechat using code [" + code + "]");
}
JSONObject object = JSONObject.parseObject(response.body());
return AuthToken.builder()
.accessToken(object.getString("access_token"))
.refreshToken(object.getString("refresh_token"))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册