From 5ec49c6c77453d8e26f27de2fdb4e6e4f3dba1cf Mon Sep 17 00:00:00 2001 From: "Yangkai.Shen" <237497819@qq.com> Date: Thu, 23 May 2019 11:13:32 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20=E4=BF=AE=E5=A4=8DQQ=E7=99=BB=E5=BD=95?= =?UTF-8?q?=EF=BC=8C=E8=8E=B7=E5=8F=96=E7=94=A8=E6=88=B7=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E9=9C=80=E8=A6=81=E6=90=BA=E5=B8=A6=20clientId?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/me/zhyd/oauth/request/AuthQqRequest.java | 3 ++- src/main/java/me/zhyd/oauth/utils/UrlBuilder.java | 9 +++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/java/me/zhyd/oauth/request/AuthQqRequest.java b/src/main/java/me/zhyd/oauth/request/AuthQqRequest.java index fd39087..8f2c8f4 100644 --- a/src/main/java/me/zhyd/oauth/request/AuthQqRequest.java +++ b/src/main/java/me/zhyd/oauth/request/AuthQqRequest.java @@ -48,7 +48,8 @@ public class AuthQqRequest extends BaseAuthRequest { protected AuthUser getUserInfo(AuthToken authToken) { String accessToken = authToken.getAccessToken(); String openId = this.getOpenId(accessToken); - HttpResponse response = HttpRequest.get(UrlBuilder.getQqUserInfoUrl(accessToken, openId)).execute(); + HttpResponse response = HttpRequest.get(UrlBuilder.getQqUserInfoUrl(config.getClientId(), accessToken, openId)) + .execute(); JSONObject object = JSONObject.parseObject(response.body()); if (object.getIntValue("ret") != 0) { throw new AuthException(object.getString("msg")); diff --git a/src/main/java/me/zhyd/oauth/utils/UrlBuilder.java b/src/main/java/me/zhyd/oauth/utils/UrlBuilder.java index e4a1c11..989f3a9 100644 --- a/src/main/java/me/zhyd/oauth/utils/UrlBuilder.java +++ b/src/main/java/me/zhyd/oauth/utils/UrlBuilder.java @@ -56,7 +56,7 @@ public class UrlBuilder { private static final String ALIPAY_AUTHORIZE_PATTERN = "{0}?app_id={1}&scope=auth_user&redirect_uri={2}&state=init"; private static final String QQ_ACCESS_TOKEN_PATTERN = "{0}?client_id={1}&client_secret={2}&grant_type=authorization_code&code={3}&redirect_uri={4}"; - private static final String QQ_USER_INFO_PATTERN = "{0}?access_token={1}&oauth_consumer_key=12345&openid={2}"; + private static final String QQ_USER_INFO_PATTERN = "{0}?oauth_consumer_key={1}&access_token={2}&openid={3}"; private static final String QQ_AUTHORIZE_PATTERN = "{0}?client_id={1}&response_type=code&redirect_uri={2}&state={3}"; private static final String QQ_OPENID_PATTERN = "{0}?access_token={1}"; @@ -395,8 +395,8 @@ public class UrlBuilder { * @param openId qq 应用的openId * @return full url */ - public static String getQqUserInfoUrl(String token, String openId) { - return MessageFormat.format(QQ_USER_INFO_PATTERN, ApiUrl.QQ.userInfo(), token, openId); + public static String getQqUserInfoUrl(String clientId, String token, String openId) { + return MessageFormat.format(QQ_USER_INFO_PATTERN, ApiUrl.QQ.userInfo(), clientId, token, openId); } /** @@ -543,7 +543,8 @@ public class UrlBuilder { * @return full url */ public static String getFacebookAuthorizeUrl(String clientId, String redirectUrl) { - return MessageFormat.format(FACEBOOK_AUTHORIZE_PATTERN, ApiUrl.FACEBOOK.authorize(), clientId, redirectUrl, System.currentTimeMillis()); + return MessageFormat.format(FACEBOOK_AUTHORIZE_PATTERN, ApiUrl.FACEBOOK.authorize(), clientId, redirectUrl, System + .currentTimeMillis()); } /** -- GitLab