1
0
mirror of synced 2026-04-22 01:18:37 +08:00

🔖 增加stackoverflow参数校验、解决Pinterest获取用户失败的问题,发布v1.9.1

This commit is contained in:
yadong.zhang
2019-07-20 17:21:21 +08:00
parent 1244524da0
commit 798e7556ba
16 changed files with 44 additions and 21 deletions

View File

@@ -80,6 +80,7 @@ public abstract class AuthDefaultRequest implements AuthRequest {
/**
* 返回获取accessToken的url
*
* @param code 授权码
* @return 返回获取accessToken的url
*/
protected String accessTokenUrl(String code) {
@@ -95,6 +96,7 @@ public abstract class AuthDefaultRequest implements AuthRequest {
/**
* 返回获取accessToken的url
*
* @param refreshToken refreshToken
* @return 返回获取accessToken的url
*/
protected String refreshTokenUrl(String refreshToken) {
@@ -110,6 +112,7 @@ public abstract class AuthDefaultRequest implements AuthRequest {
/**
* 返回获取userInfo的url
*
* @param authToken token
* @return 返回获取userInfo的url
*/
protected String userInfoUrl(AuthToken authToken) {
@@ -119,6 +122,7 @@ public abstract class AuthDefaultRequest implements AuthRequest {
/**
* 返回获取revoke authorization的url
*
* @param authToken token
* @return 返回获取revoke authorization的url
*/
protected String revokeUrl(AuthToken authToken) {

View File

@@ -76,7 +76,7 @@ public class AuthDingTalkRequest extends AuthDefaultRequest {
/**
* 返回获取userInfo的url
*
* @param authToken
* @param authToken 用户授权后的token
* @return 返回获取userInfo的url
*/
@Override

View File

@@ -80,7 +80,7 @@ public class AuthGoogleRequest extends AuthDefaultRequest {
/**
* 返回获取userInfo的url
*
* @param authToken
* @param authToken 用户授权后的token
* @return 返回获取userInfo的url
*/
@Override

View File

@@ -200,7 +200,7 @@ public class AuthLinkedinRequest extends AuthDefaultRequest {
/**
* 返回获取userInfo的url
*
* @param authToken
* @param authToken 用户授权后的token
* @return 返回获取userInfo的url
*/
@Override

View File

@@ -128,7 +128,7 @@ public class AuthMiRequest extends AuthDefaultRequest {
/**
* 返回获取userInfo的url
*
* @param authToken
* @param authToken 用户授权后的token
* @return 返回获取userInfo的url
*/
@Override

View File

@@ -139,7 +139,7 @@ public class AuthMicrosoftRequest extends AuthDefaultRequest {
/**
* 返回获取userInfo的url
*
* @param authToken
* @param authToken 用户授权后的token
* @return 返回获取userInfo的url
*/
@Override
@@ -150,7 +150,7 @@ public class AuthMicrosoftRequest extends AuthDefaultRequest {
/**
* 返回获取accessToken的url
*
* @param refreshToken
* @param refreshToken 用户授权后的token
* @return 返回获取accessToken的url
*/
@Override

View File

@@ -77,7 +77,7 @@ public class AuthOschinaRequest extends AuthDefaultRequest {
/**
* 返回获取userInfo的url
*
* @param authToken
* @param authToken 用户授权后的token
* @return 返回获取userInfo的url
*/
@Override

View File

@@ -43,10 +43,8 @@ public class AuthPinterestRequest extends AuthDefaultRequest {
@Override
protected AuthUser getUserInfo(AuthToken authToken) {
String userinfoUrl = UrlBuilder.fromBaseUrl(userInfoUrl(authToken))
.queryParam("fields", "id,username,first_name,last_name,bio,image")
.build();
HttpResponse response = HttpRequest.post(userinfoUrl).execute();
String userinfoUrl = userInfoUrl(authToken);
HttpResponse response = HttpRequest.get(userinfoUrl).setFollowRedirects(true).execute();
JSONObject object = JSONObject.parseObject(response.body());
this.checkResponse(object);
JSONObject userObj = object.getJSONObject("data");
@@ -82,6 +80,19 @@ public class AuthPinterestRequest extends AuthDefaultRequest {
.build();
}
/**
* 返回获取userInfo的url
*
* @param authToken token
* @return 返回获取userInfo的url
*/
protected String userInfoUrl(AuthToken authToken) {
return UrlBuilder.fromBaseUrl(source.userInfo())
.queryParam("access_token", authToken.getAccessToken())
.queryParam("fields", "id,username,first_name,last_name,bio,image")
.build();
}
/**
* 检查响应内容是否正确
*

View File

@@ -100,7 +100,7 @@ public class AuthRenrenRequest extends AuthDefaultRequest {
/**
* 返回获取userInfo的url
*
* @param authToken
* @param authToken 用户授权后的token
* @return 返回获取userInfo的url
*/
@Override

View File

@@ -76,7 +76,7 @@ public class AuthWeiboRequest extends AuthDefaultRequest {
/**
* 返回获取userInfo的url
*
* @param authToken
* @param authToken authToken
* @return 返回获取userInfo的url
*/
@Override

View File

@@ -26,6 +26,9 @@ public class AuthChecker {
if (isSupported && AuthSource.ALIPAY == source) {
isSupported = StringUtils.isNotEmpty(config.getAlipayPublicKey());
}
if (isSupported && AuthSource.STACK_OVERFLOW == source) {
isSupported = StringUtils.isNotEmpty(config.getStackOverflowKey());
}
return isSupported;
}

View File

@@ -45,7 +45,7 @@ public class GlobalAuthUtil {
}
}
private static String urlEncode(String value) {
public static String urlEncode(String value) {
if (value == null) {
return "";
}

View File

@@ -14,7 +14,6 @@ import java.util.Map;
* </p>
*
* @author yangkai.shen (https://xkcoding.com)
* @date Created in 2019-07-18 15:47
* @version 1.0
* @since 1.8
*/