提交 ee1b6c8c 编写于 作者: 智布道's avatar 智布道 👁

集成酷家乐

上级 2be048ef
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
</p> </p>
<p align="center"> <p align="center">
<a target="_blank" href="https://search.maven.org/search?q=JustAuth"> <a target="_blank" href="https://search.maven.org/search?q=JustAuth">
<img src="https://img.shields.io/badge/Maven Central-1.10.1-blue.svg" ></img> <img src="https://img.shields.io/badge/Maven Central-1.11.0-blue.svg" ></img>
</a> </a>
<a target="_blank" href="https://gitee.com/yadong.zhang/JustAuth/blob/master/LICENSE"> <a target="_blank" href="https://gitee.com/yadong.zhang/JustAuth/blob/master/LICENSE">
<img src="https://img.shields.io/apm/l/vim-mode.svg?color=yellow" ></img> <img src="https://img.shields.io/apm/l/vim-mode.svg?color=yellow" ></img>
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<img src="https://img.shields.io/badge/JDK-1.8+-green.svg" ></img> <img src="https://img.shields.io/badge/JDK-1.8+-green.svg" ></img>
</a> </a>
<a target="_blank" href="https://apidoc.gitee.com/yadong.zhang/JustAuth/" title="API文档"> <a target="_blank" href="https://apidoc.gitee.com/yadong.zhang/JustAuth/" title="API文档">
<img src="https://img.shields.io/badge/Api Docs-1.10.1-orange.svg" ></img> <img src="https://img.shields.io/badge/Api Docs-1.11.0-orange.svg" ></img>
</a> </a>
<a target="_blank" href="https://docs.justauth.whnb.wang" title="参考文档"> <a target="_blank" href="https://docs.justauth.whnb.wang" title="参考文档">
<img src="https://img.shields.io/badge/Docs-latest-blueviolet.svg" ></img> <img src="https://img.shields.io/badge/Docs-latest-blueviolet.svg" ></img>
...@@ -64,6 +64,7 @@ ...@@ -64,6 +64,7 @@
<td align="center" width="200"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/huawei.png" width="20"></td> <td align="center" width="200"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/huawei.png" width="20"></td>
<td align="center" width="200"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/wechat.png" width="20" title="微信企业版"></td> <td align="center" width="200"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/wechat.png" width="20" title="微信企业版"></td>
<td align="center" width="200"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/csdn.png" width="20"></td> <td align="center" width="200"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/csdn.png" width="20"></td>
<td align="center" width="200"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/kujiale.png" width="20"></td>
</tr> </tr>
</table> </table>
</center> </center>
...@@ -91,7 +92,7 @@ These artifacts are available from Maven Central: ...@@ -91,7 +92,7 @@ These artifacts are available from Maven Central:
<dependency> <dependency>
<groupId>me.zhyd.oauth</groupId> <groupId>me.zhyd.oauth</groupId>
<artifactId>JustAuth</artifactId> <artifactId>JustAuth</artifactId>
<version>1.10.1</version> <version>1.11.0</version>
</dependency> </dependency>
``` ```
- Using JustAuth - Using JustAuth
...@@ -103,7 +104,7 @@ AuthRequest authRequest = new AuthGiteeRequest(AuthConfig.builder() ...@@ -103,7 +104,7 @@ AuthRequest authRequest = new AuthGiteeRequest(AuthConfig.builder()
.redirectUri("redirectUri") .redirectUri("redirectUri")
.build()); .build());
// Generate authorization url // 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 // 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. // 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); authRequest.login(callback);
...@@ -147,6 +148,7 @@ authRequest.login(callback); ...@@ -147,6 +148,7 @@ authRequest.login(callback);
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/huawei.png" width="20"> | [AuthHuaweiRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthHuaweiRequest.java) | <a href="https://developer.huawei.com/consumer/cn/devservice/doc/30101" target="_blank">参考文档</a> | | <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/huawei.png" width="20"> | [AuthHuaweiRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthHuaweiRequest.java) | <a href="https://developer.huawei.com/consumer/cn/devservice/doc/30101" target="_blank">参考文档</a> |
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/wechat.png" width="20"> | [AuthWeChatEnterpriseRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthWeChatEnterpriseRequest.java) | <a href="https://open.work.weixin.qq.com/api/doc#90000/90135/90664" target="_blank">参考文档</a> | | <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/wechat.png" width="20"> | [AuthWeChatEnterpriseRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthWeChatEnterpriseRequest.java) | <a href="https://open.work.weixin.qq.com/api/doc#90000/90135/90664" target="_blank">参考文档</a> |
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/csdn.png" width="20"> | [AuthCsdnRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthCsdnRequest.java) | 无 | | <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/csdn.png" width="20"> | [AuthCsdnRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthCsdnRequest.java) | 无 |
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/kujiale.png" width="20"> | [AuthKujialeRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthKujialeRequest.java) | <a href="https://open.kujiale.com/open/apps/2/docs?doc_id=95" target="_blank">参考文档</a> |
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
</p> </p>
<p align="center"> <p align="center">
<a target="_blank" href="https://search.maven.org/search?q=JustAuth"> <a target="_blank" href="https://search.maven.org/search?q=JustAuth">
<img src="https://img.shields.io/badge/Maven Central-1.10.1-blue.svg" ></img> <img src="https://img.shields.io/badge/Maven Central-1.11.0-blue.svg" ></img>
</a> </a>
<a target="_blank" href="https://gitee.com/yadong.zhang/JustAuth/blob/master/LICENSE"> <a target="_blank" href="https://gitee.com/yadong.zhang/JustAuth/blob/master/LICENSE">
<img src="https://img.shields.io/apm/l/vim-mode.svg?color=yellow" ></img> <img src="https://img.shields.io/apm/l/vim-mode.svg?color=yellow" ></img>
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<img src="https://img.shields.io/badge/JDK-1.8+-green.svg" ></img> <img src="https://img.shields.io/badge/JDK-1.8+-green.svg" ></img>
</a> </a>
<a target="_blank" href="https://apidoc.gitee.com/yadong.zhang/JustAuth/" title="API文档"> <a target="_blank" href="https://apidoc.gitee.com/yadong.zhang/JustAuth/" title="API文档">
<img src="https://img.shields.io/badge/Api Docs-1.10.1-orange.svg" ></img> <img src="https://img.shields.io/badge/Api Docs-1.11.0-orange.svg" ></img>
</a> </a>
<a target="_blank" href="https://docs.justauth.whnb.wang" title="参考文档"> <a target="_blank" href="https://docs.justauth.whnb.wang" title="参考文档">
<img src="https://img.shields.io/badge/Docs-latest-blueviolet.svg" ></img> <img src="https://img.shields.io/badge/Docs-latest-blueviolet.svg" ></img>
...@@ -64,7 +64,7 @@ ...@@ -64,7 +64,7 @@
<td align="center" width="200"><a href="#授权华为"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/huawei.png" width="20"></a></td> <td align="center" width="200"><a href="#授权华为"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/huawei.png" width="20"></a></td>
<td align="center" width="200"><a href="#授权微信企业版" title="微信企业版"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/wechat.png" width="20"></a></td> <td align="center" width="200"><a href="#授权微信企业版" title="微信企业版"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/wechat.png" width="20"></a></td>
<td align="center" width="200"><a href="#授权csdn"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/csdn.png" width="20"></a></td> <td align="center" width="200"><a href="#授权csdn"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/csdn.png" width="20"></a></td>
<td align="center" width="200"><a href="#授权酷家乐"><img src="https://qhstatic.kujiale.com/oauth2/images/logo_24.png" width="20"></a></td> <td align="center" width="200"><a href="#授权酷家乐"><img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/kujiale.png" width="20"></a></td>
</tr> </tr>
</table> </table>
</center> </center>
...@@ -92,7 +92,7 @@ JustAuth,如你所见,它仅仅是一个**第三方授权登录**的**工具 ...@@ -92,7 +92,7 @@ JustAuth,如你所见,它仅仅是一个**第三方授权登录**的**工具
<dependency> <dependency>
<groupId>me.zhyd.oauth</groupId> <groupId>me.zhyd.oauth</groupId>
<artifactId>JustAuth</artifactId> <artifactId>JustAuth</artifactId>
<version>1.10.1</version> <version>1.11.0</version>
</dependency> </dependency>
``` ```
- 调用api - 调用api
...@@ -104,7 +104,7 @@ AuthRequest authRequest = new AuthGiteeRequest(AuthConfig.builder() ...@@ -104,7 +104,7 @@ AuthRequest authRequest = new AuthGiteeRequest(AuthConfig.builder()
.redirectUri("redirectUri") .redirectUri("redirectUri")
.build()); .build());
// 生成授权页面 // 生成授权页面
authRequest.authorize(); authRequest.authorize("state");
// 授权登录后会返回code(auth_code(仅限支付宝))、state,1.8.0版本后,可以用AuthCallback类作为回调接口的参数 // 授权登录后会返回code(auth_code(仅限支付宝))、state,1.8.0版本后,可以用AuthCallback类作为回调接口的参数
// 注:JustAuth默认保存state的时效为3分钟,3分钟内未使用则会自动清除过期的state // 注:JustAuth默认保存state的时效为3分钟,3分钟内未使用则会自动清除过期的state
authRequest.login(callback); authRequest.login(callback);
...@@ -158,7 +158,7 @@ authRequest.login(callback); ...@@ -158,7 +158,7 @@ authRequest.login(callback);
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/huawei.png" width="20"> | [AuthHuaweiRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthHuaweiRequest.java) | <a href="https://developer.huawei.com/consumer/cn/devservice/doc/30101" target="_blank">参考文档</a> | | <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/huawei.png" width="20"> | [AuthHuaweiRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthHuaweiRequest.java) | <a href="https://developer.huawei.com/consumer/cn/devservice/doc/30101" target="_blank">参考文档</a> |
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/wechat.png" width="20"> | [AuthWeChatEnterpriseRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthWeChatEnterpriseRequest.java) | <a href="https://open.work.weixin.qq.com/api/doc#90000/90135/90664" target="_blank">参考文档</a> | | <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/wechat.png" width="20"> | [AuthWeChatEnterpriseRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthWeChatEnterpriseRequest.java) | <a href="https://open.work.weixin.qq.com/api/doc#90000/90135/90664" target="_blank">参考文档</a> |
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/csdn.png" width="20"> | [AuthCsdnRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthCsdnRequest.java) | 无 | | <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/csdn.png" width="20"> | [AuthCsdnRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthCsdnRequest.java) | 无 |
| <img src="https://qhstatic.kujiale.com/oauth2/images/logo_24.png" width="20"> | [AuthKujialeRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthKujialeRequest.java) | <a href="https://open.kujiale.com/open/apps/2/docs?doc_id=95" target="_blank">参考文档</a> | | <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/kujiale.png" width="20"> | [AuthKujialeRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthKujialeRequest.java) | <a href="https://open.kujiale.com/open/apps/2/docs?doc_id=95" target="_blank">参考文档</a> |
_请知悉:经咨询CSDN官方客服得知,CSDN的授权开放平台已经下线。如果以前申请过的应用,可以继续使用,但是不再支持申请新的应用。so, 本项目中的CSDN登录只能针对少部分用户使用了_ _请知悉:经咨询CSDN官方客服得知,CSDN的授权开放平台已经下线。如果以前申请过的应用,可以继续使用,但是不再支持申请新的应用。so, 本项目中的CSDN登录只能针对少部分用户使用了_
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
</p> </p>
<p align="center"> <p align="center">
<a target="_blank" href="https://search.maven.org/search?q=JustAuth"> <a target="_blank" href="https://search.maven.org/search?q=JustAuth">
<img src="https://img.shields.io/badge/Maven Central-1.10.1-blue.svg" ></img> <img src="https://img.shields.io/badge/Maven Central-1.11.0-blue.svg" ></img>
</a> </a>
<a target="_blank" href="https://gitee.com/yadong.zhang/JustAuth/blob/master/LICENSE"> <a target="_blank" href="https://gitee.com/yadong.zhang/JustAuth/blob/master/LICENSE">
<img src="https://img.shields.io/apm/l/vim-mode.svg?color=yellow" ></img> <img src="https://img.shields.io/apm/l/vim-mode.svg?color=yellow" ></img>
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
<img src="https://img.shields.io/badge/JDK-1.8+-green.svg" ></img> <img src="https://img.shields.io/badge/JDK-1.8+-green.svg" ></img>
</a> </a>
<a target="_blank" href="https://apidoc.gitee.com/yadong.zhang/JustAuth/" title="API文档"> <a target="_blank" href="https://apidoc.gitee.com/yadong.zhang/JustAuth/" title="API文档">
<img src="https://img.shields.io/badge/Api Docs-1.10.1-orange.svg" ></img> <img src="https://img.shields.io/badge/Api Docs-1.11.0-orange.svg" ></img>
</a> </a>
<a target="_blank" href="https://docs.justauth.whnb.wang" title="参考文档"> <a target="_blank" href="https://docs.justauth.whnb.wang" title="参考文档">
<img src="https://img.shields.io/badge/Docs-latest-blueviolet.svg" ></img> <img src="https://img.shields.io/badge/Docs-latest-blueviolet.svg" ></img>
...@@ -88,6 +88,7 @@ JustAuth,如你所见,它仅仅是一个**第三方授权登录**的**工具 ...@@ -88,6 +88,7 @@ JustAuth,如你所见,它仅仅是一个**第三方授权登录**的**工具
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/huawei.png" width="20"> | [AuthHuaweiRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthHuaweiRequest.java) | <a href="https://developer.huawei.com/consumer/cn/devservice/doc/30101" target="_blank">参考文档</a> | | <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/huawei.png" width="20"> | [AuthHuaweiRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthHuaweiRequest.java) | <a href="https://developer.huawei.com/consumer/cn/devservice/doc/30101" target="_blank">参考文档</a> |
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/wechat.png" width="20"> | [AuthWeChatEnterpriseRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthWeChatEnterpriseRequest.java) | <a href="https://open.work.weixin.qq.com/api/doc#90000/90135/90664" target="_blank">参考文档</a> | | <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/wechat.png" width="20"> | [AuthWeChatEnterpriseRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthWeChatEnterpriseRequest.java) | <a href="https://open.work.weixin.qq.com/api/doc#90000/90135/90664" target="_blank">参考文档</a> |
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/csdn.png" width="20"> | [AuthCsdnRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthCsdnRequest.java) | 无 | | <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/csdn.png" width="20"> | [AuthCsdnRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthCsdnRequest.java) | 无 |
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/kujiale.png" width="20"> | [AuthKujialeRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthKujialeRequest.java) | <a href="https://open.kujiale.com/open/apps/2/docs?doc_id=95" target="_blank">参考文档</a> |
## 快速开始 ## 快速开始
...@@ -97,7 +98,7 @@ JustAuth,如你所见,它仅仅是一个**第三方授权登录**的**工具 ...@@ -97,7 +98,7 @@ JustAuth,如你所见,它仅仅是一个**第三方授权登录**的**工具
<dependency> <dependency>
<groupId>me.zhyd.oauth</groupId> <groupId>me.zhyd.oauth</groupId>
<artifactId>JustAuth</artifactId> <artifactId>JustAuth</artifactId>
<version>1.10.1</version> <version>1.11.0</version>
</dependency> </dependency>
``` ```
- 调用api - 调用api
...@@ -109,7 +110,7 @@ AuthRequest authRequest = new AuthGiteeRequest(AuthConfig.builder() ...@@ -109,7 +110,7 @@ AuthRequest authRequest = new AuthGiteeRequest(AuthConfig.builder()
.redirectUri("redirectUri") .redirectUri("redirectUri")
.build()); .build());
// 生成授权页面 // 生成授权页面
authRequest.authorize(); authRequest.authorize("state");
// 授权登录后会返回code(auth_code(仅限支付宝))、state,1.8.0版本后,可以用AuthCallback类作为回调接口的参数 // 授权登录后会返回code(auth_code(仅限支付宝))、state,1.8.0版本后,可以用AuthCallback类作为回调接口的参数
// 注:JustAuth默认保存state的时效为3分钟,3分钟内未使用则会自动清除过期的state // 注:JustAuth默认保存state的时效为3分钟,3分钟内未使用则会自动清除过期的state
authRequest.login(callback); authRequest.login(callback);
......
![](_media/logo.png) ![](_media/logo.png)
# JustAuth <small>1.10.1</small> # JustAuth <small>1.11.0</small>
<strong>史上最全的整合第三方登录的开源库</strong> <strong>史上最全的整合第三方登录的开源库</strong>
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
<dependency> <dependency>
<groupId>me.zhyd.oauth</groupId> <groupId>me.zhyd.oauth</groupId>
<artifactId>JustAuth</artifactId> <artifactId>JustAuth</artifactId>
<version>1.10.1</version> <version>1.11.0</version>
</dependency> </dependency>
``` ```
- 调用api - 调用api
...@@ -26,7 +26,7 @@ AuthRequest authRequest = new AuthGiteeRequest(AuthConfig.builder() ...@@ -26,7 +26,7 @@ AuthRequest authRequest = new AuthGiteeRequest(AuthConfig.builder()
.redirectUri("redirectUri") .redirectUri("redirectUri")
.build()); .build());
// 生成授权页面 // 生成授权页面
authRequest.authorize(); authRequest.authorize("state");
// 授权登录后会返回code(auth_code(仅限支付宝))、state,1.8.0版本后,可以用AuthCallback类作为回调接口的参数 // 授权登录后会返回code(auth_code(仅限支付宝))、state,1.8.0版本后,可以用AuthCallback类作为回调接口的参数
// 注:JustAuth默认保存state的时效为3分钟,3分钟内未使用则会自动清除过期的state // 注:JustAuth默认保存state的时效为3分钟,3分钟内未使用则会自动清除过期的state
authRequest.login(callback); authRequest.login(callback);
......
## v1.11.0
### 2019/09/02
- 集成“酷家乐”授权登录
## v1.10.1 ## v1.10.1
### 2019/08/17 ### 2019/08/17
......
...@@ -6,12 +6,13 @@ ...@@ -6,12 +6,13 @@
<groupId>me.zhyd.oauth</groupId> <groupId>me.zhyd.oauth</groupId>
<artifactId>JustAuth</artifactId> <artifactId>JustAuth</artifactId>
<version>1.10.1</version> <version>1.11.0</version>
<name>JustAuth</name> <name>JustAuth</name>
<url>https://gitee.com/yadong.zhang/JustAuth</url> <url>https://gitee.com/yadong.zhang/JustAuth</url>
<description> <description>
史上最全的整合第三方登录的工具,目前已支持Github、Gitee、酷家乐、微博、钉钉、百度、Coding、腾讯云开发者平台、OSChina、支付宝、QQ、微信、淘宝、Google、Facebook、抖音、领英、小米、微软和今日头条等第三方平台的授权登录。 史上最全的整合第三方登录的开源库。目前已支持Github、Gitee、微博、钉钉、百度、Coding、腾讯云开发者平台、OSChina、支付宝、
QQ、微信、淘宝、Google、Facebook、抖音、领英、小米、微软、今日头条、Teambition、StackOverflow、Pinterest、人人、华为、企业微信和酷家乐等第三方平台的授权登录。
Login, so easy! Login, so easy!
</description> </description>
......
...@@ -571,7 +571,7 @@ public enum AuthSource { ...@@ -571,7 +571,7 @@ public enum AuthSource {
/** /**
* 酷家乐 * 酷家乐
* *
* @since 1.10.1 * @since 1.11.0
*/ */
KUJIALE { KUJIALE {
@Override @Override
......
...@@ -16,9 +16,10 @@ import me.zhyd.oauth.utils.StringUtils; ...@@ -16,9 +16,10 @@ import me.zhyd.oauth.utils.StringUtils;
import me.zhyd.oauth.utils.UrlBuilder; import me.zhyd.oauth.utils.UrlBuilder;
/** /**
* 酷家乐授权登录
*
* @author shahuang * @author shahuang
* @Date: 2019/8/29 18:50 * @since 1.11.0
* @since 1.10.1
*/ */
public class AuthKujialeRequest extends AuthDefaultRequest { public class AuthKujialeRequest extends AuthDefaultRequest {
...@@ -33,9 +34,10 @@ public class AuthKujialeRequest extends AuthDefaultRequest { ...@@ -33,9 +34,10 @@ public class AuthKujialeRequest extends AuthDefaultRequest {
/** /**
* 返回带{@code state}参数的授权url,授权回调时会带上这个{@code state} * 返回带{@code state}参数的授权url,授权回调时会带上这个{@code state}
* 默认只向用户请求用户信息授权 * 默认只向用户请求用户信息授权
*
* @param state state 验证授权流程的参数,可以防止csrf * @param state state 验证授权流程的参数,可以防止csrf
* @return 返回授权地址 * @return 返回授权地址
* @since 1.10.1 * @since 1.11.0
*/ */
@Override @Override
public String authorize(String state) { public String authorize(String state) {
...@@ -44,10 +46,11 @@ public class AuthKujialeRequest extends AuthDefaultRequest { ...@@ -44,10 +46,11 @@ public class AuthKujialeRequest extends AuthDefaultRequest {
/** /**
* 请求授权url * 请求授权url
* @param state state 验证授权流程的参数,可以防止csrf *
* @param state state 验证授权流程的参数,可以防止csrf
* @param scopeStr 请求用户授权时向用户显示的可进行授权的列表。如果要填写多个接口名称,请用逗号隔开 * @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字段 * 参考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) { public String authorize(String state, String scopeStr) {
UrlBuilder urlBuilder = UrlBuilder.fromBaseUrl(source.authorize()) UrlBuilder urlBuilder = UrlBuilder.fromBaseUrl(source.authorize())
...@@ -68,11 +71,7 @@ public class AuthKujialeRequest extends AuthDefaultRequest { ...@@ -68,11 +71,7 @@ public class AuthKujialeRequest extends AuthDefaultRequest {
} }
private AuthToken getAuthToken(HttpResponse response) { private AuthToken getAuthToken(HttpResponse response) {
String accessTokenStr = response.body(); JSONObject accessTokenObject = checkResponse(response);
JSONObject accessTokenObject = JSONObject.parseObject(accessTokenStr);
if (!"0".equals(accessTokenObject.getString("c"))) {
throw new AuthException(accessTokenObject.getString("m"));
}
JSONObject resultObject = accessTokenObject.getJSONObject("d"); JSONObject resultObject = accessTokenObject.getJSONObject("d");
return AuthToken.builder() return AuthToken.builder()
.accessToken(resultObject.getString("accessToken")) .accessToken(resultObject.getString("accessToken"))
...@@ -81,6 +80,15 @@ public class AuthKujialeRequest extends AuthDefaultRequest { ...@@ -81,6 +80,15 @@ public class AuthKujialeRequest extends AuthDefaultRequest {
.build(); .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 @Override
public AuthUser getUserInfo(AuthToken authToken) { public AuthUser getUserInfo(AuthToken authToken) {
String openId = this.getOpenId(authToken); String openId = this.getOpenId(authToken);
...@@ -114,11 +122,7 @@ public class AuthKujialeRequest extends AuthDefaultRequest { ...@@ -114,11 +122,7 @@ public class AuthKujialeRequest extends AuthDefaultRequest {
HttpResponse response = HttpRequest.get(UrlBuilder.fromBaseUrl("https://oauth.kujiale.com/oauth2/auth/user") HttpResponse response = HttpRequest.get(UrlBuilder.fromBaseUrl("https://oauth.kujiale.com/oauth2/auth/user")
.queryParam("access_token", authToken.getAccessToken()) .queryParam("access_token", authToken.getAccessToken())
.build()).execute(); .build()).execute();
String accessTokenStr = response.body(); JSONObject accessTokenObject = checkResponse(response);
JSONObject accessTokenObject = JSONObject.parseObject(accessTokenStr);
if (!"0".equals(accessTokenObject.getString("c"))) {
throw new AuthException(accessTokenObject.getString("m"));
}
return accessTokenObject.getString("d"); return accessTokenObject.getString("d");
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册