🐛 修复QQ登录,获取用户信息需要携带 clientId
This commit is contained in:
@@ -48,7 +48,8 @@ public class AuthQqRequest extends BaseAuthRequest {
|
|||||||
protected AuthUser getUserInfo(AuthToken authToken) {
|
protected AuthUser getUserInfo(AuthToken authToken) {
|
||||||
String accessToken = authToken.getAccessToken();
|
String accessToken = authToken.getAccessToken();
|
||||||
String openId = this.getOpenId(accessToken);
|
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());
|
JSONObject object = JSONObject.parseObject(response.body());
|
||||||
if (object.getIntValue("ret") != 0) {
|
if (object.getIntValue("ret") != 0) {
|
||||||
throw new AuthException(object.getString("msg"));
|
throw new AuthException(object.getString("msg"));
|
||||||
|
|||||||
@@ -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 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_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_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}";
|
private static final String QQ_OPENID_PATTERN = "{0}?access_token={1}";
|
||||||
|
|
||||||
@@ -395,8 +395,8 @@ public class UrlBuilder {
|
|||||||
* @param openId qq 应用的openId
|
* @param openId qq 应用的openId
|
||||||
* @return full url
|
* @return full url
|
||||||
*/
|
*/
|
||||||
public static String getQqUserInfoUrl(String token, String openId) {
|
public static String getQqUserInfoUrl(String clientId, String token, String openId) {
|
||||||
return MessageFormat.format(QQ_USER_INFO_PATTERN, ApiUrl.QQ.userInfo(), token, openId);
|
return MessageFormat.format(QQ_USER_INFO_PATTERN, ApiUrl.QQ.userInfo(), clientId, token, openId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -543,7 +543,8 @@ public class UrlBuilder {
|
|||||||
* @return full url
|
* @return full url
|
||||||
*/
|
*/
|
||||||
public static String getFacebookAuthorizeUrl(String clientId, String redirectUrl) {
|
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());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user