diff --git a/README.md b/README.md
index 8b541fb90eab882afc3cc2526930d5dd528af781..93ab65ee92029ea1af519526182ef3f9fcbfd7b3 100644
--- a/README.md
+++ b/README.md
@@ -20,18 +20,19 @@
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
+ |
+ |
+ |
+ |
+ |
+ |
+ |
+ |
+ |
+ |
+ |
+ |
+ |
@@ -48,6 +49,7 @@
支付宝 |
QQ |
微信 |
+ 淘宝 |
@@ -94,7 +96,7 @@ authRequest.login("code");
|:------:|:-------:|:-------:|
| | [AuthGiteeRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthGiteeRequest.java) | 参考文档 |
| | [AuthGithubRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthGiteeRequest.java) | 参考文档 |
-| | [AuthWeiboRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthGiteeRequest.java) | 参考文档 |
+| | [AuthWeiboRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthGiteeRequest.java) | 参考文档 |
| | [AuthDingTalkRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthDingTalkRequest.java) | 参考文档 |
| | [AuthBaiduRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthBaiduRequest.java) | 参考文档 |
| | [AuthCodingRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthCodingRequest.java) | 参考文档 |
@@ -103,7 +105,8 @@ authRequest.login("code");
| | [AuthAlipayRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthAlipayRequest.java) | 参考文档 |
| | [AuthQqRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthQqRequest.java) | 参考文档 |
| | [AuthCsdnRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthCsdnRequest.java) | 待续 |
-| | [AuthWeChatRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthCsdnRequest.java) | 参考文档 |
+| | [AuthWeChatRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthWeChatRequest.java) | 参考文档 |
+| | [AuthTaobaoRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthTaobaoRequest.java) | 参考文档 |
## 后续开发计划
@@ -168,6 +171,10 @@ authRequest.login("code");
待续
+#### 授权淘宝
+
+待续
+
# 交流
| 微信(备注:加群) | 公众号 |
diff --git a/pom.xml b/pom.xml
index 75473004035577d308427ba0221cc3e38e4e1dc0..25fd8f8c540beafc3d604a6668accdd5a46e6511 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
me.zhyd.oauth
JustAuth
- 1.1.0
+ 1.2.0
JustAuth
https://gitee.com/yadong.zhang/JustAuth
diff --git a/src/main/java/me/zhyd/oauth/consts/ApiUrl.java b/src/main/java/me/zhyd/oauth/consts/ApiUrl.java
index e895b89a00b7b99507956eca07d857118de2d1e7..a99eb02ef1bab1bcc6bb4044d8fa0103fd633b8d 100644
--- a/src/main/java/me/zhyd/oauth/consts/ApiUrl.java
+++ b/src/main/java/me/zhyd/oauth/consts/ApiUrl.java
@@ -358,6 +358,35 @@ public enum ApiUrl {
public String refresh() {
return "https://api.weixin.qq.com/sns/oauth2/refresh_token";
}
+ },
+ /**
+ * 淘宝
+ */
+ TAOBAO {
+ @Override
+ public String authorize() {
+ return "https://oauth.taobao.com/authorize";
+ }
+
+ @Override
+ public String accessToken() {
+ return "https://oauth.taobao.com/token";
+ }
+
+ @Override
+ public String userInfo() {
+ throw new AuthException(ResponseStatus.UNSUPPORTED);
+ }
+
+ @Override
+ public String revoke() {
+ throw new AuthException(ResponseStatus.UNSUPPORTED);
+ }
+
+ @Override
+ public String refresh() {
+ throw new AuthException(ResponseStatus.UNSUPPORTED);
+ }
};
/**
diff --git a/src/main/java/me/zhyd/oauth/model/AuthSource.java b/src/main/java/me/zhyd/oauth/model/AuthSource.java
index 5a0f4932dcc95efa91aaed5dc31c1cc5c9d7f88d..7eac69de68d49da6964245e4013fc7fb66edbdb2 100644
--- a/src/main/java/me/zhyd/oauth/model/AuthSource.java
+++ b/src/main/java/me/zhyd/oauth/model/AuthSource.java
@@ -16,7 +16,7 @@ public enum AuthSource {
OSCHINA,
TENCEN_CLOUD,
ALIPAY,
-
+ TAOBAO,
QQ,
WECHAT,
GOOGLE,
diff --git a/src/main/java/me/zhyd/oauth/model/AuthToken.java b/src/main/java/me/zhyd/oauth/model/AuthToken.java
index 88ad0f38135fbf46fba820844db9e5b766b1bb61..011ece89aa2efb3b141bf8befc4b0c7b6465809f 100644
--- a/src/main/java/me/zhyd/oauth/model/AuthToken.java
+++ b/src/main/java/me/zhyd/oauth/model/AuthToken.java
@@ -12,12 +12,9 @@ import lombok.Data;
@Builder
public class AuthToken {
private String accessToken;
- private String expireIn;
+ private int expireIn;
private String refreshToken;
private String uid;
private String openId;
- /**
- * 针对钉钉
- */
private String accessCode;
}
diff --git a/src/main/java/me/zhyd/oauth/model/AuthUser.java b/src/main/java/me/zhyd/oauth/model/AuthUser.java
index 775aa2dd1aeb25f9d0e6a77e8b1ae2775a1c937a..82d15c5db7b07563790e6f25248cf9204a2d735f 100644
--- a/src/main/java/me/zhyd/oauth/model/AuthUser.java
+++ b/src/main/java/me/zhyd/oauth/model/AuthUser.java
@@ -21,5 +21,5 @@ public class AuthUser {
private String remark;
private AuthUserGender gender;
private AuthSource source;
- private String accessToken;
+ private AuthToken token;
}
diff --git a/src/main/java/me/zhyd/oauth/request/AuthAlipayRequest.java b/src/main/java/me/zhyd/oauth/request/AuthAlipayRequest.java
index d9ce1458740eea28866441a123143a27b684cb6e..461d631ca9584782a79b6beab9e0e509d928072b 100644
--- a/src/main/java/me/zhyd/oauth/request/AuthAlipayRequest.java
+++ b/src/main/java/me/zhyd/oauth/request/AuthAlipayRequest.java
@@ -72,7 +72,7 @@ public class AuthAlipayRequest extends BaseAuthRequest {
.avatar(response.getAvatar())
.location(String.format("%s %s", StringUtils.isEmpty(province) ? "" : province, StringUtils.isEmpty(city) ? "" : city))
.gender(AuthUserGender.getRealGender(response.getGender()))
- .accessToken(accessToken)
+ .token(authToken)
.source(AuthSource.ALIPAY)
.build();
}
diff --git a/src/main/java/me/zhyd/oauth/request/AuthBaiduRequest.java b/src/main/java/me/zhyd/oauth/request/AuthBaiduRequest.java
index 79299c6d07c882fd0978f3179ac9bd10bbb778f0..11abfdf7e448a8959b283e9bfebbd5510c46d46b 100644
--- a/src/main/java/me/zhyd/oauth/request/AuthBaiduRequest.java
+++ b/src/main/java/me/zhyd/oauth/request/AuthBaiduRequest.java
@@ -3,6 +3,7 @@ package me.zhyd.oauth.request;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import com.alibaba.fastjson.JSONObject;
+import lombok.extern.slf4j.Slf4j;
import me.zhyd.oauth.config.AuthConfig;
import me.zhyd.oauth.exception.AuthException;
import me.zhyd.oauth.model.*;
@@ -49,7 +50,7 @@ public class AuthBaiduRequest extends BaseAuthRequest {
.username(object.getString("username"))
.nickname(object.getString("username"))
.gender(AuthUserGender.getRealGender(object.getString("sex")))
- .accessToken(accessToken)
+ .token(authToken)
.source(AuthSource.BAIDU)
.build();
}
@@ -60,6 +61,12 @@ public class AuthBaiduRequest extends BaseAuthRequest {
HttpResponse response = HttpRequest.get(UrlBuilder.getBaiduRevokeUrl(accessToken)).execute();
String userInfo = response.body();
JSONObject object = JSONObject.parseObject(userInfo);
+ if(object.containsKey("error_code")) {
+ return AuthResponse.builder()
+ .code(ResponseStatus.FAILURE.getCode())
+ .msg(object.getString("error_msg"))
+ .build();
+ }
ResponseStatus status = object.getIntValue("result") == 1 ? ResponseStatus.SUCCESS : ResponseStatus.FAILURE;
return AuthResponse.builder().code(status.getCode()).msg(status.getMsg()).build();
}
diff --git a/src/main/java/me/zhyd/oauth/request/AuthCodingRequest.java b/src/main/java/me/zhyd/oauth/request/AuthCodingRequest.java
index 6af8bf1e91784f6b67bb6a9c64fb5da31f5864a3..485e3809ea383b020b2b216ea5164898ae61462d 100644
--- a/src/main/java/me/zhyd/oauth/request/AuthCodingRequest.java
+++ b/src/main/java/me/zhyd/oauth/request/AuthCodingRequest.java
@@ -56,7 +56,7 @@ public class AuthCodingRequest extends BaseAuthRequest {
.gender(AuthUserGender.getRealGender(object.getString("sex")))
.email(object.getString("email"))
.remark(object.getString("slogan"))
- .accessToken(accessToken)
+ .token(authToken)
.source(AuthSource.CODING)
.build();
}
diff --git a/src/main/java/me/zhyd/oauth/request/AuthCsdnRequest.java b/src/main/java/me/zhyd/oauth/request/AuthCsdnRequest.java
index d529e118246626b3d9b2dcad583de2f4d9f8deac..fd943686a96ee05a16c85ccbbb9c933455f5a29d 100644
--- a/src/main/java/me/zhyd/oauth/request/AuthCsdnRequest.java
+++ b/src/main/java/me/zhyd/oauth/request/AuthCsdnRequest.java
@@ -46,7 +46,7 @@ public class AuthCsdnRequest extends BaseAuthRequest {
}
return AuthUser.builder()
.username(object.getString("username"))
- .accessToken(accessToken)
+ .token(authToken)
.source(AuthSource.CSDN)
.build();
}
diff --git a/src/main/java/me/zhyd/oauth/request/AuthDingTalkRequest.java b/src/main/java/me/zhyd/oauth/request/AuthDingTalkRequest.java
index a9671e85c58bb073a896cca78654cd02ea8f56cb..debb44d2f077276717a69c904cbef3149730d09d 100644
--- a/src/main/java/me/zhyd/oauth/request/AuthDingTalkRequest.java
+++ b/src/main/java/me/zhyd/oauth/request/AuthDingTalkRequest.java
@@ -52,6 +52,7 @@ public class AuthDingTalkRequest extends BaseAuthRequest {
object = object.getJSONObject("user_info");
return AuthUser.builder()
.nickname(object.getStr("nick"))
+ .username(object.getStr("nick"))
.source(AuthSource.DINGTALK)
.build();
}
diff --git a/src/main/java/me/zhyd/oauth/request/AuthGiteeRequest.java b/src/main/java/me/zhyd/oauth/request/AuthGiteeRequest.java
index 557a8e22f69149a64f90707487b7243a41fd4960..9afcc431b2b26707cada54e443ad406e877fd3e7 100644
--- a/src/main/java/me/zhyd/oauth/request/AuthGiteeRequest.java
+++ b/src/main/java/me/zhyd/oauth/request/AuthGiteeRequest.java
@@ -51,7 +51,7 @@ public class AuthGiteeRequest extends BaseAuthRequest {
.location(object.getString("address"))
.email(object.getString("email"))
.remark(object.getString("bio"))
- .accessToken(accessToken)
+ .token(authToken)
.source(AuthSource.GITEE)
.build();
}
diff --git a/src/main/java/me/zhyd/oauth/request/AuthGithubRequest.java b/src/main/java/me/zhyd/oauth/request/AuthGithubRequest.java
index 3f6b34485033eb3462e161f78d4d4712076e37a7..dd73bc36f2d984b8bf342afd73842c8c84ac918f 100644
--- a/src/main/java/me/zhyd/oauth/request/AuthGithubRequest.java
+++ b/src/main/java/me/zhyd/oauth/request/AuthGithubRequest.java
@@ -54,7 +54,7 @@ public class AuthGithubRequest extends BaseAuthRequest {
.location(object.getString("location"))
.email(object.getString("email"))
.remark(object.getString("bio"))
- .accessToken(accessToken)
+ .token(authToken)
.source(AuthSource.GITHUB)
.build();
}
diff --git a/src/main/java/me/zhyd/oauth/request/AuthOschinaRequest.java b/src/main/java/me/zhyd/oauth/request/AuthOschinaRequest.java
index 061310f685146e2f60ab2de6fbe80d3617c57581..1a419accd216bb7f108f6e8e612d9a46d1945f5e 100644
--- a/src/main/java/me/zhyd/oauth/request/AuthOschinaRequest.java
+++ b/src/main/java/me/zhyd/oauth/request/AuthOschinaRequest.java
@@ -53,7 +53,7 @@ public class AuthOschinaRequest extends BaseAuthRequest {
.location(object.getString("location"))
.gender(AuthUserGender.getRealGender(object.getString("gender")))
.email(object.getString("email"))
- .accessToken(accessToken)
+ .token(authToken)
.source(AuthSource.OSCHINA)
.build();
}
diff --git a/src/main/java/me/zhyd/oauth/request/AuthQqRequest.java b/src/main/java/me/zhyd/oauth/request/AuthQqRequest.java
index d65a67817b5515cb715deb8e720e529ac0dc9a80..c58faf6c4e8bf914aa984a61b3fcf89aae840a37 100644
--- a/src/main/java/me/zhyd/oauth/request/AuthQqRequest.java
+++ b/src/main/java/me/zhyd/oauth/request/AuthQqRequest.java
@@ -55,7 +55,7 @@ public class AuthQqRequest extends BaseAuthRequest {
.nickname(object.getString("nickname"))
.avatar(avatar)
.gender(AuthUserGender.getRealGender(object.getString("gender")))
- .accessToken(accessToken)
+ .token(authToken)
.source(AuthSource.QQ)
.build();
}
diff --git a/src/main/java/me/zhyd/oauth/request/AuthTaobaoRequest.java b/src/main/java/me/zhyd/oauth/request/AuthTaobaoRequest.java
new file mode 100644
index 0000000000000000000000000000000000000000..761aa6fe28d19be96fe061f875f92dc04750b618
--- /dev/null
+++ b/src/main/java/me/zhyd/oauth/request/AuthTaobaoRequest.java
@@ -0,0 +1,58 @@
+package me.zhyd.oauth.request;
+
+import cn.hutool.http.HttpRequest;
+import cn.hutool.http.HttpResponse;
+import com.alibaba.fastjson.JSONObject;
+import me.zhyd.oauth.config.AuthConfig;
+import me.zhyd.oauth.exception.AuthException;
+import me.zhyd.oauth.model.AuthSource;
+import me.zhyd.oauth.model.AuthToken;
+import me.zhyd.oauth.model.AuthUser;
+import me.zhyd.oauth.model.AuthUserGender;
+import me.zhyd.oauth.utils.GlobalAuthUtil;
+import me.zhyd.oauth.utils.UrlBuilder;
+
+/**
+ * 淘宝登录
+ *
+ * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
+ * @version 1.0
+ * @since 1.8
+ */
+public class AuthTaobaoRequest extends BaseAuthRequest {
+
+ public AuthTaobaoRequest(AuthConfig config) {
+ super(config, AuthSource.TAOBAO);
+ }
+
+ @Override
+ protected AuthToken getAccessToken(String code) {
+ return AuthToken.builder()
+ .accessCode(code)
+ .build();
+ }
+
+ @Override
+ protected AuthUser getUserInfo(AuthToken authToken) {
+ String accessCode = authToken.getAccessCode();
+ HttpResponse response = HttpRequest.post(UrlBuilder.getTaobaoAccessTokenUrl(this.config.getClientId(), this.config.getClientSecret(), accessCode, this.config.getRedirectUri())).execute();
+ JSONObject object = JSONObject.parseObject(response.body());
+ if (object.containsKey("error")) {
+ throw new AuthException(ResponseStatus.FAILURE + ":" + object.getString("error_description"));
+ }
+ authToken.setAccessToken(object.getString("access_token"));
+ authToken.setRefreshToken(object.getString("refresh_token"));
+ authToken.setExpireIn(object.getIntValue("expires_in"));
+ authToken.setUid(object.getString("taobao_user_id"));
+ authToken.setOpenId(object.getString("taobao_open_uid"));
+
+ String nick = GlobalAuthUtil.urlDecode(object.getString("taobao_user_nick"));
+ return AuthUser.builder()
+ .username(nick)
+ .nickname(nick)
+ .gender(AuthUserGender.UNKNOW)
+ .token(authToken)
+ .source(AuthSource.TAOBAO)
+ .build();
+ }
+}
diff --git a/src/main/java/me/zhyd/oauth/request/AuthTencentCloudRequest.java b/src/main/java/me/zhyd/oauth/request/AuthTencentCloudRequest.java
index ef3d99e1eaec1880bc7fa196424bb182379ec4cd..1681f15166e974a5db37294610b1bc9833e60d17 100644
--- a/src/main/java/me/zhyd/oauth/request/AuthTencentCloudRequest.java
+++ b/src/main/java/me/zhyd/oauth/request/AuthTencentCloudRequest.java
@@ -56,7 +56,7 @@ public class AuthTencentCloudRequest extends BaseAuthRequest {
.gender(AuthUserGender.getRealGender(object.getString("sex")))
.email(object.getString("email"))
.remark(object.getString("slogan"))
- .accessToken(accessToken)
+ .token(authToken)
.source(AuthSource.TENCEN_CLOUD)
.build();
}
diff --git a/src/main/java/me/zhyd/oauth/request/AuthWeChatRequest.java b/src/main/java/me/zhyd/oauth/request/AuthWeChatRequest.java
index d74a6d4c10a1a2a35da21cfa6e7a375cf9ca8609..24587de3c5e38ff37ecde171b5c232f7741fe95c 100644
--- a/src/main/java/me/zhyd/oauth/request/AuthWeChatRequest.java
+++ b/src/main/java/me/zhyd/oauth/request/AuthWeChatRequest.java
@@ -60,7 +60,7 @@ public class AuthWeChatRequest extends BaseAuthRequest {
.avatar(object.getString("headimgurl"))
.location(object.getString("country") + "-" + object.getString("province") + "-" + object.getString("city"))
.gender(AuthUserGender.getRealGender(object.getString("sex")))
- .accessToken(accessToken)
+ .token(authToken)
.source(AuthSource.WECHAT)
.build();
}
diff --git a/src/main/java/me/zhyd/oauth/request/AuthWeiboRequest.java b/src/main/java/me/zhyd/oauth/request/AuthWeiboRequest.java
index 12d51a2d9dfc9c4a27a8a74f00dbbf5edd648555..7c6e92b3518ec5196cf4a8fe9ff6c7e11941e714 100644
--- a/src/main/java/me/zhyd/oauth/request/AuthWeiboRequest.java
+++ b/src/main/java/me/zhyd/oauth/request/AuthWeiboRequest.java
@@ -35,24 +35,28 @@ public class AuthWeiboRequest extends BaseAuthRequest {
String accessTokenStr = response.body();
JSONObject accessTokenObject = JSONObject.parseObject(accessTokenStr);
if (accessTokenObject.containsKey("error")) {
- throw new AuthException("Unable to get token from gitee using code [" + code + "]");
+ throw new AuthException("Unable to get token from weibo using code [" + code + "]:" + accessTokenObject.getString("error_description"));
}
- String accessToken = accessTokenObject.getString("access_token");
- String uid = accessTokenObject.getString("uid");
return AuthToken.builder()
- .accessToken(String.format("uid=%s&access_token=%s", uid, accessToken))
+ .accessToken(accessTokenObject.getString("access_token"))
+ .uid(accessTokenObject.getString("uid"))
+ .expireIn(accessTokenObject.getIntValue("remind_in"))
.build();
}
@Override
protected AuthUser getUserInfo(AuthToken authToken) {
String accessToken = authToken.getAccessToken();
+ String uid = authToken.getUid();
HttpResponse response = HttpRequest.get(UrlBuilder.getWeiboUserInfoUrl(accessToken))
- .header("Authorization", "OAuth2 " + accessToken)
+ .header("Authorization", "OAuth2 " + String.format("uid=%s&access_token=%s", uid, accessToken))
.header("API-RemoteIP", IpUtils.getIp())
.execute();
String userInfo = response.body();
JSONObject object = JSONObject.parseObject(userInfo);
+ if(object.containsKey("error")) {
+ throw new AuthException(object.getString("error"));
+ }
return AuthUser.builder()
.username(object.getString("name"))
.avatar(object.getString("profile_image_url"))
@@ -61,7 +65,7 @@ public class AuthWeiboRequest extends BaseAuthRequest {
.location(object.getString("location"))
.remark(object.getString("description"))
.gender(AuthUserGender.getRealGender(object.getString("gender")))
- .accessToken(GlobalAuthUtil.parseStringToMap(accessToken).get("access_token"))
+ .token(authToken)
.source(AuthSource.WEIBO)
.build();
}
diff --git a/src/main/java/me/zhyd/oauth/request/BaseAuthRequest.java b/src/main/java/me/zhyd/oauth/request/BaseAuthRequest.java
index 09e59015fda654cf444d8a04c8645e247caa5e0c..afc839c28c0a6649d6d895f177712c24cd6b6e65 100644
--- a/src/main/java/me/zhyd/oauth/request/BaseAuthRequest.java
+++ b/src/main/java/me/zhyd/oauth/request/BaseAuthRequest.java
@@ -82,6 +82,9 @@ public abstract class BaseAuthRequest implements AuthRequest {
case WECHAT:
authorizeUrl = UrlBuilder.getWeChatAuthorizeUrl(config.getClientId(), config.getRedirectUri());
break;
+ case TAOBAO:
+ authorizeUrl = UrlBuilder.getTaobaoAuthorizeUrl(config.getClientId(), config.getRedirectUri());
+ break;
case GOOGLE:
break;
default:
diff --git a/src/main/java/me/zhyd/oauth/utils/UrlBuilder.java b/src/main/java/me/zhyd/oauth/utils/UrlBuilder.java
index 590cc6e233a7aa5c3412b391ca951d4138b797f7..1e0feab4b0561505d05bf541517313e1a6c40d94 100644
--- a/src/main/java/me/zhyd/oauth/utils/UrlBuilder.java
+++ b/src/main/java/me/zhyd/oauth/utils/UrlBuilder.java
@@ -61,6 +61,9 @@ public class UrlBuilder {
private static final String WECHAT_REFRESH_TOKEN_PATTERN = "{0}?appid={1}&grant_type=refresh_token&refresh_token={2}";
private static final String WECHAT_USER_INFO_PATTERN = "{0}?access_token={1}&openid={2}&lang=zh_CN";
+ private static final String TAOBAO_AUTHORIZE_PATTERN = "{0}?response_type=code&client_id={1}&redirect_uri={2}&state=&view=web";
+ private static final String TAOBAO_ACCESS_TOKEN_PATTERN = "{0}?client_id={1}&client_secret={2}&code={3}&redirect_uri={4}&grant_type=authorization_code";
+
/**
* 获取githubtoken的接口地址
*
@@ -465,4 +468,28 @@ public class UrlBuilder {
public static String getWeChatRefreshUrl(String clientId, String refreshToken) {
return MessageFormat.format(WECHAT_REFRESH_TOKEN_PATTERN, ApiUrl.WECHAT.refresh(), clientId, refreshToken);
}
+
+ /**
+ * 获取Taobao token的接口地址: 淘宝的授权登录,在这一步就会返回用户信息
+ *
+ * @param clientId taobao应用的App Key
+ * @param clientSecret taobao应用的App Secret
+ * @param code taobao授权前的code,用来换token
+ * @param redirectUri 待跳转的页面
+ * @return full url
+ */
+ public static String getTaobaoAccessTokenUrl(String clientId, String clientSecret, String code, String redirectUri) {
+ return MessageFormat.format(TAOBAO_ACCESS_TOKEN_PATTERN, ApiUrl.TAOBAO.accessToken(), clientId, clientSecret, code, redirectUri);
+ }
+
+ /**
+ * 获取Taobao授权地址
+ *
+ * @param clientId Taobao 应用的Client ID
+ * @param redirectUrl Taobao 应用授权成功后的回调地址
+ * @return full url
+ */
+ public static String getTaobaoAuthorizeUrl(String clientId, String redirectUrl) {
+ return MessageFormat.format(TAOBAO_AUTHORIZE_PATTERN, ApiUrl.TAOBAO.authorize(), clientId, redirectUrl);
+ }
}
diff --git a/update.md b/update.md
new file mode 100644
index 0000000000000000000000000000000000000000..41654e93ffbdeb2976675474720a6ea0c88d37eb
--- /dev/null
+++ b/update.md
@@ -0,0 +1,10 @@
+
+### 2019/05/18
+1. 迭代到1.1.0版本,发布jar包
+2. 支持淘宝登录
+3. 修改`AuthUser.java`类中的`accessToken`属性,由原本的~~accessToken (String)~~改为`token (AuthToken)`
+
+----
+### 2019/05/17
+1. 增加qq和微信的授权登录
+2. 修改getAccessToken方法的返回值
\ No newline at end of file