diff --git a/README.en-US.md b/README.en-US.md
index cdb2936a1632a29085f80f5f69df55a8f8d6f4a1..7617b2396801c27ce3cf6b1f518a395713790972 100644
--- a/README.en-US.md
+++ b/README.en-US.md
@@ -6,7 +6,7 @@
-
+
@@ -15,7 +15,7 @@
-
+
@@ -64,6 +64,7 @@
|
|
|
+ |
@@ -91,7 +92,7 @@ These artifacts are available from Maven Central:
me.zhyd.oauth
JustAuth
- 1.10.1
+ 1.11.0
```
- Using JustAuth
@@ -103,7 +104,7 @@ AuthRequest authRequest = new AuthGiteeRequest(AuthConfig.builder()
.redirectUri("redirectUri")
.build());
// Generate authorization url
-authRequest.authorize();
+authRequest.authorize("state");
// After authorization to login, it will return: code(auth_code(Alipay only)),state, After version 1.8.0, you can use the AuthCallback as a parameter to the callback interface
// Note: JustAuth saves state for 3 minutes by default. If it is not used within 3 minutes, the expired state will be cleared automatically.
authRequest.login(callback);
@@ -147,6 +148,7 @@ authRequest.login(callback);
| | [AuthHuaweiRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthHuaweiRequest.java) | 参考文档 |
| | [AuthWeChatEnterpriseRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthWeChatEnterpriseRequest.java) | 参考文档 |
| | [AuthCsdnRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthCsdnRequest.java) | 无 |
+| | [AuthKujialeRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthKujialeRequest.java) | 参考文档 |
diff --git a/README.md b/README.md
index 9b605cdcd0599807eecd41f78b3688b8af963081..31823e2a5d1e8adc4f6423ca555ff4f92eec84d3 100644
--- a/README.md
+++ b/README.md
@@ -6,7 +6,7 @@
-
+
@@ -15,7 +15,7 @@
-
+
@@ -64,7 +64,7 @@
|
|
|
- |
+ |
@@ -92,7 +92,7 @@ JustAuth,如你所见,它仅仅是一个**第三方授权登录**的**工具
me.zhyd.oauth
JustAuth
- 1.10.1
+ 1.11.0
```
- 调用api
@@ -104,7 +104,7 @@ AuthRequest authRequest = new AuthGiteeRequest(AuthConfig.builder()
.redirectUri("redirectUri")
.build());
// 生成授权页面
-authRequest.authorize();
+authRequest.authorize("state");
// 授权登录后会返回code(auth_code(仅限支付宝))、state,1.8.0版本后,可以用AuthCallback类作为回调接口的参数
// 注:JustAuth默认保存state的时效为3分钟,3分钟内未使用则会自动清除过期的state
authRequest.login(callback);
@@ -158,7 +158,7 @@ authRequest.login(callback);
| | [AuthHuaweiRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthHuaweiRequest.java) | 参考文档 |
| | [AuthWeChatEnterpriseRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthWeChatEnterpriseRequest.java) | 参考文档 |
| | [AuthCsdnRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthCsdnRequest.java) | 无 |
-| | [AuthKujialeRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthKujialeRequest.java) | 参考文档 |
+| | [AuthKujialeRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthKujialeRequest.java) | 参考文档 |
_请知悉:经咨询CSDN官方客服得知,CSDN的授权开放平台已经下线。如果以前申请过的应用,可以继续使用,但是不再支持申请新的应用。so, 本项目中的CSDN登录只能针对少部分用户使用了_
diff --git a/docs/README.md b/docs/README.md
index 04349f445967364967ad930c933de2820c6afdca..735a61a095cff20d1a2fb9b42dd0bd56c3c02cbe 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -9,7 +9,7 @@
-
+
@@ -18,7 +18,7 @@
-
+
@@ -88,6 +88,7 @@ JustAuth,如你所见,它仅仅是一个**第三方授权登录**的**工具
| | [AuthHuaweiRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthHuaweiRequest.java) | 参考文档 |
| | [AuthWeChatEnterpriseRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthWeChatEnterpriseRequest.java) | 参考文档 |
| | [AuthCsdnRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthCsdnRequest.java) | 无 |
+| | [AuthKujialeRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthKujialeRequest.java) | 参考文档 |
## 快速开始
@@ -97,7 +98,7 @@ JustAuth,如你所见,它仅仅是一个**第三方授权登录**的**工具
me.zhyd.oauth
JustAuth
- 1.10.1
+ 1.11.0
```
- 调用api
@@ -109,7 +110,7 @@ AuthRequest authRequest = new AuthGiteeRequest(AuthConfig.builder()
.redirectUri("redirectUri")
.build());
// 生成授权页面
-authRequest.authorize();
+authRequest.authorize("state");
// 授权登录后会返回code(auth_code(仅限支付宝))、state,1.8.0版本后,可以用AuthCallback类作为回调接口的参数
// 注:JustAuth默认保存state的时效为3分钟,3分钟内未使用则会自动清除过期的state
authRequest.login(callback);
diff --git a/docs/_coverpage.md b/docs/_coverpage.md
index 03062e370958247529e7d20f57c8774cd067b39d..3b3c450315e2a6c1db72f1d8cb51b71539c3257b 100644
--- a/docs/_coverpage.md
+++ b/docs/_coverpage.md
@@ -1,6 +1,6 @@
![](_media/logo.png)
-# JustAuth 1.10.1
+# JustAuth 1.11.0
史上最全的整合第三方登录的开源库
diff --git a/docs/how-to-use.md b/docs/how-to-use.md
index c83d3993d444077e157a47c32b5471d3843b7dda..bc0e7947c94e403b313cea769bf4112f828d731c 100644
--- a/docs/how-to-use.md
+++ b/docs/how-to-use.md
@@ -14,7 +14,7 @@
me.zhyd.oauth
JustAuth
- 1.10.1
+ 1.11.0
```
- 调用api
@@ -26,7 +26,7 @@ AuthRequest authRequest = new AuthGiteeRequest(AuthConfig.builder()
.redirectUri("redirectUri")
.build());
// 生成授权页面
-authRequest.authorize();
+authRequest.authorize("state");
// 授权登录后会返回code(auth_code(仅限支付宝))、state,1.8.0版本后,可以用AuthCallback类作为回调接口的参数
// 注:JustAuth默认保存state的时效为3分钟,3分钟内未使用则会自动清除过期的state
authRequest.login(callback);
diff --git a/docs/update.md b/docs/update.md
index 3d3c690c8727ee8c87c87c453b729b33d794805b..2a4ace318adf2b3fe4f6db0aaf50ab6d9310c960 100644
--- a/docs/update.md
+++ b/docs/update.md
@@ -1,3 +1,8 @@
+## v1.11.0
+### 2019/09/02
+
+- 集成“酷家乐”授权登录
+
## v1.10.1
### 2019/08/17
diff --git a/pom.xml b/pom.xml
index 7da8895e21ac1a6ee4c0c569baabcafce4c18894..b1b93f0e16467e69dc228f0b3e0ac2d9d23aebc2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,12 +6,13 @@
me.zhyd.oauth
JustAuth
- 1.10.1
+ 1.11.0
JustAuth
https://gitee.com/yadong.zhang/JustAuth
- 史上最全的整合第三方登录的工具,目前已支持Github、Gitee、酷家乐、微博、钉钉、百度、Coding、腾讯云开发者平台、OSChina、支付宝、QQ、微信、淘宝、Google、Facebook、抖音、领英、小米、微软和今日头条等第三方平台的授权登录。
+ 史上最全的整合第三方登录的开源库。目前已支持Github、Gitee、微博、钉钉、百度、Coding、腾讯云开发者平台、OSChina、支付宝、
+ QQ、微信、淘宝、Google、Facebook、抖音、领英、小米、微软、今日头条、Teambition、StackOverflow、Pinterest、人人、华为、企业微信和酷家乐等第三方平台的授权登录。
Login, so easy!
diff --git a/src/main/java/me/zhyd/oauth/config/AuthSource.java b/src/main/java/me/zhyd/oauth/config/AuthSource.java
index 4ba65993036ac3e263c83b351c25af0cb877299b..db64121d0030395b97908a193553c3f36a9d00a3 100644
--- a/src/main/java/me/zhyd/oauth/config/AuthSource.java
+++ b/src/main/java/me/zhyd/oauth/config/AuthSource.java
@@ -571,7 +571,7 @@ public enum AuthSource {
/**
* 酷家乐
*
- * @since 1.10.1
+ * @since 1.11.0
*/
KUJIALE {
@Override
diff --git a/src/main/java/me/zhyd/oauth/request/AuthKujialeRequest.java b/src/main/java/me/zhyd/oauth/request/AuthKujialeRequest.java
index 446624a83507a04160c2df8416186e0daddeeba8..833b7e21f75d421f7ff0af99ea7269abcb9afc28 100644
--- a/src/main/java/me/zhyd/oauth/request/AuthKujialeRequest.java
+++ b/src/main/java/me/zhyd/oauth/request/AuthKujialeRequest.java
@@ -16,9 +16,10 @@ import me.zhyd.oauth.utils.StringUtils;
import me.zhyd.oauth.utils.UrlBuilder;
/**
+ * 酷家乐授权登录
+ *
* @author shahuang
- * @Date: 2019/8/29 18:50
- * @since 1.10.1
+ * @since 1.11.0
*/
public class AuthKujialeRequest extends AuthDefaultRequest {
@@ -33,9 +34,10 @@ public class AuthKujialeRequest extends AuthDefaultRequest {
/**
* 返回带{@code state}参数的授权url,授权回调时会带上这个{@code state}
* 默认只向用户请求用户信息授权
+ *
* @param state state 验证授权流程的参数,可以防止csrf
* @return 返回授权地址
- * @since 1.10.1
+ * @since 1.11.0
*/
@Override
public String authorize(String state) {
@@ -44,10 +46,11 @@ public class AuthKujialeRequest extends AuthDefaultRequest {
/**
* 请求授权url
- * @param state state 验证授权流程的参数,可以防止csrf
+ *
+ * @param state state 验证授权流程的参数,可以防止csrf
* @param scopeStr 请求用户授权时向用户显示的可进行授权的列表。如果要填写多个接口名称,请用逗号隔开
* 参考https://open.kujiale.com/open/apps/2/docs?doc_id=95#Step1%EF%BC%9A%E8%8E%B7%E5%8F%96Authorization%20Code参数表内的scope字段
- * @return
+ * @return authorize url
*/
public String authorize(String state, String scopeStr) {
UrlBuilder urlBuilder = UrlBuilder.fromBaseUrl(source.authorize())
@@ -68,11 +71,7 @@ public class AuthKujialeRequest extends AuthDefaultRequest {
}
private AuthToken getAuthToken(HttpResponse response) {
- String accessTokenStr = response.body();
- JSONObject accessTokenObject = JSONObject.parseObject(accessTokenStr);
- if (!"0".equals(accessTokenObject.getString("c"))) {
- throw new AuthException(accessTokenObject.getString("m"));
- }
+ JSONObject accessTokenObject = checkResponse(response);
JSONObject resultObject = accessTokenObject.getJSONObject("d");
return AuthToken.builder()
.accessToken(resultObject.getString("accessToken"))
@@ -81,6 +80,15 @@ public class AuthKujialeRequest extends AuthDefaultRequest {
.build();
}
+ private JSONObject checkResponse(HttpResponse response) {
+ String accessTokenStr = response.body();
+ JSONObject accessTokenObject = JSONObject.parseObject(accessTokenStr);
+ if (!"0".equals(accessTokenObject.getString("c"))) {
+ throw new AuthException(accessTokenObject.getString("m"));
+ }
+ return accessTokenObject;
+ }
+
@Override
public AuthUser getUserInfo(AuthToken authToken) {
String openId = this.getOpenId(authToken);
@@ -114,11 +122,7 @@ public class AuthKujialeRequest extends AuthDefaultRequest {
HttpResponse response = HttpRequest.get(UrlBuilder.fromBaseUrl("https://oauth.kujiale.com/oauth2/auth/user")
.queryParam("access_token", authToken.getAccessToken())
.build()).execute();
- String accessTokenStr = response.body();
- JSONObject accessTokenObject = JSONObject.parseObject(accessTokenStr);
- if (!"0".equals(accessTokenObject.getString("c"))) {
- throw new AuthException(accessTokenObject.getString("m"));
- }
+ JSONObject accessTokenObject = checkResponse(response);
return accessTokenObject.getString("d");
}