Compare commits
21 Commits
1.15.2-alpha
...
1.15.5
| Author | SHA1 | Date | |
|---|---|---|---|
| 89b5fe4543 | |||
| 6f313fa91a | |||
| 36bcebdd46 | |||
| 99b8680fd2 | |||
| 2717d9cf7a | |||
| 166ddffaf4 | |||
| 33385fd30a | |||
| 8e5a679129 | |||
| 5ab2e87157 | |||
| c34e226a54 | |||
| e4985c63f3 | |||
| e93ad07c5f | |||
| 4ca1f46722 | |||
| 571c3438e4 | |||
| 2497519ec1 | |||
| 278a435cdb | |||
| e75df92080 | |||
| 9e6a4c61b0 | |||
| d355699cc3 | |||
| 28466f8ab5 | |||
| c6bd5d9e5d |
@@ -6,7 +6,7 @@
|
||||
</p>
|
||||
<p align="center">
|
||||
<a target="_blank" href="https://search.maven.org/search?q=JustAuth">
|
||||
<img src="https://img.shields.io/badge/Maven%20Central--1.15.2-alpha-blue" ></img>
|
||||
<img src="https://img.shields.io/badge/Maven%20Central--1.15.5-blue" ></img>
|
||||
</a>
|
||||
<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>
|
||||
@@ -15,7 +15,7 @@
|
||||
<img src="https://img.shields.io/badge/JDK-1.8+-green.svg" ></img>
|
||||
</a>
|
||||
<a target="_blank" href="https://apidoc.gitee.com/yadong.zhang/JustAuth/" title="API文档">
|
||||
<img src="https://img.shields.io/badge/Api%20Docs--1.15.2-alpha-latest-orange" ></img>
|
||||
<img src="https://img.shields.io/badge/Api%20Docs--1.15.5-latest-orange" ></img>
|
||||
</a>
|
||||
<a target="_blank" href="https://docs.justauth.whnb.wang" title="参考文档">
|
||||
<img src="https://img.shields.io/badge/Docs-latest-blueviolet.svg" ></img>
|
||||
@@ -97,7 +97,7 @@ These artifacts are available from Maven Central:
|
||||
<dependency>
|
||||
<groupId>me.zhyd.oauth</groupId>
|
||||
<artifactId>JustAuth</artifactId>
|
||||
<version>1.15.2-alpha</version>
|
||||
<version>1.15.5</version>
|
||||
</dependency>
|
||||
```
|
||||
- Using JustAuth
|
||||
@@ -148,57 +148,6 @@ Note, that since [v1.14.0](https://gitee.com/yadong.zhang/JustAuth/releases/v1.1
|
||||
</dependency>
|
||||
```
|
||||
|
||||
|
||||
**Examples**:
|
||||
- [Springboot Example](https://github.com/justauth/JustAuth-demo)
|
||||
- [jFinal Example](https://github.com/xkcoding/jfinal-justauth-demo): by [xkcoding](https://github.com/xkcoding)
|
||||
- [ActFramework Example](https://github.com/xkcoding/act-justauth-demo): by [xkcoding](https://github.com/xkcoding)
|
||||
- [Nutzboot Example](https://github.com/EggsBlue/nutzboot-justauth-demo): by [蛋蛋](https://github.com/EggsBlue)
|
||||
- [Blade Example](https://github.com/justauth/blade-justauth-demo)
|
||||
|
||||
**Springboot Starter**
|
||||
|
||||
- [justauth-spring-boot-starter](https://github.com/xkcoding/justauth-spring-boot-starter): Spring Boot integrates best practices with JustAuth by [xkcoding](https://github.com/xkcoding)
|
||||
- [justauth-spring-boot-starter-demo](https://github.com/justauth/justauth-spring-boot-starter-demo): Justauth-spring-boot-starter demo project by [xkcoding](https://github.com/xkcoding)
|
||||
|
||||
#### API
|
||||
| :computer: platform | :coffee: API | :page_facing_up: Official document |
|
||||
|:------:|:-------:|:-------:|
|
||||
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/gitee.png" width="20"> | [AuthGiteeRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthGiteeRequest.java) | <a href="https://gitee.com/api/v5/oauth_doc#list_1" target="_blank">参考文档</a> |
|
||||
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/github.png" width="20"> | [AuthGithubRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthGithubRequest.java) | <a href="https://developer.github.com/apps/building-oauth-apps/authorizing-oauth-apps/" target="_blank">参考文档</a> |
|
||||
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/weibo.png" width="20"> | [AuthWeiboRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthWeiboRequest.java) | <a href="https://open.weibo.com/wiki/%E6%8E%88%E6%9D%83%E6%9C%BA%E5%88%B6%E8%AF%B4%E6%98%8E" target="_blank">参考文档</a> |
|
||||
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/dingtalk.png" width="20"> | [AuthDingTalkRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthDingTalkRequest.java) | <a href="https://open-doc.dingtalk.com/microapp/serverapi2/kymkv6" target="_blank">参考文档</a> |
|
||||
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/baidu.png" width="20"> | [AuthBaiduRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthBaiduRequest.java) | <a href="http://developer.baidu.com/wiki/index.php?title=docs/oauth" target="_blank">参考文档</a> |
|
||||
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/coding.png" width="25"> | [AuthCodingRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthCodingRequest.java) | <a href="https://open.coding.net/references/oauth/" target="_blank">参考文档</a> |
|
||||
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/tencentCloud.png" width="25"> | [AuthTencentCloudRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthTencentCloudRequest.java) | <a href="https://dev.tencent.com/help/doc/faq/b4e5b7aee786/oauth" target="_blank">参考文档</a> |
|
||||
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/oschina.png" width="20"> | [AuthOschinaRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthOschinaRequest.java) | <a href="https://www.oschina.net/openapi/docs/oauth2_authorize" target="_blank">参考文档</a> |
|
||||
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/alipay.png" width="20"> | [AuthAlipayRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthAlipayRequest.java) | <a href="https://alipay.open.taobao.com/docs/doc.htm?spm=a219a.7629140.0.0.336d4b70GUKXOl&treeId=193&articleId=105809&docType=1" target="_blank">参考文档</a> |
|
||||
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/qq.png" width="20"> | [AuthQqRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthQqRequest.java) | <a href="https://wiki.connect.qq.com/%E4%BD%BF%E7%94%A8authorization_code%E8%8E%B7%E5%8F%96access_token" target="_blank">参考文档</a> |
|
||||
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/wechat.png" width="20" title="微信开放平台"> | [AuthWeChatOpenRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthWeChatOpenRequest.java) | <a href="https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=open1419316505&token=&lang=zh_CN" target="_blank">参考文档</a> |
|
||||
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/wechat.png" width="20" title="微信公众平台"> | [AuthWeChatMpRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthWeChatMpRequest.java) | <a href="https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/Wechat_webpage_authorization.html" target="_blank">参考文档</a> |
|
||||
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/wechat.png" width="20" title="企业微信"> | [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/taobao.png" width="20"> | [AuthTaobaoRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthTaobaoRequest.java) | <a href="https://open.taobao.com/doc.htm?spm=a219a.7386797.0.0.4e00669acnkQy6&source=search&docId=105590&docType=1" target="_blank">参考文档</a> |
|
||||
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/google.png" width="20"> | [AuthGoogleRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthGoogleRequest.java) | <a href="https://developers.google.com/identity/protocols/OpenIDConnect" target="_blank">参考文档</a> |
|
||||
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/facebook.png" width="20"> | [AuthFacebookRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthFacebookRequest.java) | <a href="https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow" target="_blank">参考文档</a> |
|
||||
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/douyin.png" width="20"> | [AuthDouyinRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthDouyinRequest.java) | <a href="https://www.douyin.com/platform/doc/m-2-1-1" target="_blank">参考文档</a> |
|
||||
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/linkedin.png" width="20"> | [AuthLinkedinRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthLinkedinRequest.java) | <a href="https://docs.microsoft.com/zh-cn/linkedin/shared/authentication/authorization-code-flow?context=linkedin/context" target="_blank">参考文档</a> |
|
||||
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/microsoft.png" width="20"> | [AuthMicrosoftRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthMicrosoftRequest.java) | <a href="https://docs.microsoft.com/zh-cn/graph/auth/" target="_blank">参考文档</a> |
|
||||
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/mi.png" width="20"> | [AuthMiRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthMiRequest.java) | <a href="https://dev.mi.com/console/doc/detail?pId=711" target="_blank">参考文档</a> |
|
||||
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/toutiao.png" width="20"> | [AuthToutiaoRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthToutiaoRequest.java) | <a href="https://open.mp.toutiao.com/#/resource?_k=y7mfgk" target="_blank">参考文档</a> |
|
||||
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/teambition.png" width="20"> | [AuthTeambitionRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthTeambitionRequest.java) | <a href="https://docs.teambition.com/" target="_blank">参考文档</a> |
|
||||
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/renren.png" width="20"> | [AuthRenrenRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthRenrenRequest.java) | <a href="http://open.renren.com/wiki/OAuth2.0" target="_blank">参考文档</a> |
|
||||
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/pinterest.png" width="20"> | [AuthPinterestRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthPinterestRequest.java) | <a href="https://developers.pinterest.com/docs/api/overview/?" target="_blank">参考文档</a> |
|
||||
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/stackoverflow.png" width="20"> | [AuthStackOverflowRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthStackOverflowRequest.java) | <a href="https://api.stackexchange.com/docs/authentication" 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/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> |
|
||||
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/gitlab.png" width="20"> | [AuthGitlabRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthGitlabRequest.java) | <a href="https://docs.gitlab.com/ee/api/oauth2.html" target="_blank">参考文档</a> |
|
||||
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/meituan.png" width="20"> | [AuthMeituanRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthMeituanRequest.java) | <a href="http://open.waimai.meituan.com/openapi_docs/oauth/" target="_blank">参考文档</a> |
|
||||
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/eleme.png" width="20"> | [AuthElemeRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthElemeRequest.java) | <a href="https://open.shop.ele.me/openapi/documents/khd001" target="_blank">参考文档</a> |
|
||||
| <img src="https://gitee.com/yadong.zhang/static/raw/master/JustAuth/twitter.png" width="20"> | [AuthTwitterRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthTwitterRequest.java) | <a href="https://developer.twitter.com/en/docs/twitter-for-websites/log-in-with-twitter/guides/implementing-sign-in-with-twitter" 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) | 无 |
|
||||
|
||||
|
||||
|
||||
## Contributions
|
||||
|
||||
1. Fork this project to your repository
|
||||
@@ -215,6 +164,10 @@ I look forward to your joining us.
|
||||
|
||||
[contributors](https://docs.justauth.whnb.wang/#/contributors)
|
||||
|
||||
## Change Logs
|
||||
|
||||
[CHANGELOGS](https://docs.justauth.whnb.wang/#/update)
|
||||
|
||||
## Recommend
|
||||
|
||||
- `spring-boot-demo` In-depth study and actual combat of spring boot projects: [https://github.com/xkcoding/spring-boot-demo](https://github.com/xkcoding/spring-boot-demo)
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
</p>
|
||||
<p align="center">
|
||||
<a target="_blank" href="https://search.maven.org/search?q=JustAuth">
|
||||
<img src="https://img.shields.io/badge/Maven%20Central--1.15.2-alpha-blue" ></img>
|
||||
<img src="https://img.shields.io/badge/Maven%20Central--1.15.5-blue" ></img>
|
||||
</a>
|
||||
<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>
|
||||
@@ -15,7 +15,7 @@
|
||||
<img src="https://img.shields.io/badge/JDK-1.8+-green.svg" ></img>
|
||||
</a>
|
||||
<a target="_blank" href="https://apidoc.gitee.com/yadong.zhang/JustAuth/" title="API文档">
|
||||
<img src="https://img.shields.io/badge/Api%20Docs--1.15.2-alpha-latest-orange" ></img>
|
||||
<img src="https://img.shields.io/badge/Api%20Docs-1.15.5-latest-orange" ></img>
|
||||
</a>
|
||||
<a target="_blank" href="https://docs.justauth.whnb.wang" title="参考文档">
|
||||
<img src="https://img.shields.io/badge/Docs-latest-blueviolet.svg" ></img>
|
||||
@@ -96,7 +96,7 @@ JustAuth,如你所见,它仅仅是一个**第三方授权登录**的**工具
|
||||
<dependency>
|
||||
<groupId>me.zhyd.oauth</groupId>
|
||||
<artifactId>JustAuth</artifactId>
|
||||
<version>1.15.2-alpha</version>
|
||||
<version>1.15.5</version>
|
||||
</dependency>
|
||||
```
|
||||
- 调用api
|
||||
@@ -165,6 +165,10 @@ authRequest.login(callback);
|
||||
|
||||
[contributors](https://docs.justauth.whnb.wang/#/contributors)
|
||||
|
||||
## 更新记录
|
||||
|
||||
[CHANGELOGS](https://docs.justauth.whnb.wang/#/update)
|
||||
|
||||
## 致谢
|
||||
|
||||
在项目立项初期,也对当前开源圈的一些相同类型的项目作过调研,同时本项目也参考过这些项目,再次感谢开源圈内的朋友。
|
||||
|
||||
@@ -1 +1 @@
|
||||
1.15.2-alpha
|
||||
1.15.5
|
||||
|
||||
@@ -150,4 +150,15 @@ AuthRequest authRequest = new AuthQqRequest(AuthConfig.builder()
|
||||
|
||||
ps: 我要去祭天了
|
||||
|
||||
## 13. 为什么集成国外平台时,一直提示 `connect time out`?
|
||||
|
||||
所有国外平台都无法直接通过java进行访问API,目前[simple-http](https://github.com/xkcoding/simple-http) Release版本,暂不支持添加代理,所以目前需要手动开启代理。
|
||||
|
||||
代理开启的方式:
|
||||
```java
|
||||
System.setProperty("proxyPort", "10080");
|
||||
System.setProperty("proxyHost", "127.0.0.1");
|
||||
```
|
||||
以上代码可以在声明 `AuthRequest` 时创建,也可以全局执行。
|
||||
|
||||
本地如果支持科学上网,就用自己本地的代理端口即可,如果不支持科学上网,可以去网上找一些免费的代理IP进行测试(请自行操作)。
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
</p>
|
||||
<p align="center">
|
||||
<a target="_blank" href="https://search.maven.org/search?q=JustAuth">
|
||||
<img src="https://img.shields.io/badge/Maven%20Central--1.15.2-alpha-blue" ></img>
|
||||
<img src="https://img.shields.io/badge/Maven%20Central--1.15.5-blue" ></img>
|
||||
</a>
|
||||
<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>
|
||||
@@ -18,7 +18,7 @@
|
||||
<img src="https://img.shields.io/badge/JDK-1.8+-green.svg" ></img>
|
||||
</a>
|
||||
<a target="_blank" href="https://apidoc.gitee.com/yadong.zhang/JustAuth/" title="API文档">
|
||||
<img src="https://img.shields.io/badge/Api%20Docs--1.15.2-alpha-latest-orange" ></img>
|
||||
<img src="https://img.shields.io/badge/Api%20Docs-1.15.5-orange" ></img>
|
||||
</a>
|
||||
<a target="_blank" href="https://docs.justauth.whnb.wang" title="参考文档">
|
||||
<img src="https://img.shields.io/badge/Docs-latest-blueviolet.svg" ></img>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
# :alien: 404:alien:
|
||||
|
||||
**非常感谢您对JustAuth的关注**,您现在查询的内容,作者正在补充中!
|
||||
**非常感谢您对JustAuth的关注**,您现在查询的内容,作者**正在补充**中!
|
||||
|
||||
您可能对以下文章感兴趣:
|
||||
### 您可能对以下文章感兴趣:
|
||||
|
||||
- [OAuth的授权流程是什么样的?](https://docs.justauth.whnb.wang/#/oauth)
|
||||
- [如何使用JustAuth?](https://docs.justauth.whnb.wang/#/how-to-use)
|
||||
@@ -25,6 +25,9 @@
|
||||
- [酷家乐登录](oauth/kujiale.md)
|
||||
- 更多文章,正在补充中...
|
||||
|
||||
### 其他资料
|
||||
|
||||
- [参考文档](references.md)
|
||||
|
||||
### 如果还是没有您想要的内容,您可以:
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||

|
||||
# JustAuth <small>1.15.2-alpha</small>
|
||||
# JustAuth <small>1.15.5</small>
|
||||
|
||||
<strong>史上最全的整合第三方登录的开源库</strong>
|
||||
|
||||
|
||||
|
After Width: | Height: | Size: 283 KiB |
|
After Width: | Height: | Size: 53 KiB |
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 61 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 22 KiB |
|
After Width: | Height: | Size: 116 KiB |
|
After Width: | Height: | Size: 53 KiB |
|
After Width: | Height: | Size: 51 KiB |
|
After Width: | Height: | Size: 27 KiB |
|
After Width: | Height: | Size: 31 KiB |
@@ -13,15 +13,16 @@
|
||||
- [√ 微博登录](oauth/weibo.md)
|
||||
- [√ 支付宝登录](oauth/alipay.md)
|
||||
- [√ 酷家乐登录](oauth/kujiale.md)
|
||||
- [√ 推特登录](oauth/twitter.md)
|
||||
- [√ Coding登录](oauth/coding.md)
|
||||
- [√ 阿里云登录](oauth/aliyun.md)
|
||||
- [CSDN登录](oauth/csdn.md)
|
||||
- [微信企业版登录](oauth/wechatEnterprise.md)
|
||||
- [微信公众平台登录](oauth/wechat_mp.md)
|
||||
- [百度登录](oauth/baidu.md)
|
||||
- [Coding登录](oauth/coding.md)
|
||||
- [钉钉登录](oauth/dingtalk.md)
|
||||
- [开源中国登录](oauth/oschina.md)
|
||||
- [淘宝登录](oauth/taobao.md)
|
||||
- [腾讯云登录](oauth/tencentCloud.md)
|
||||
- [Google登录](oauth/google.md)
|
||||
- [Facebook登录](oauth/facebook.md)
|
||||
- [抖音登录](oauth/douyin.md)
|
||||
@@ -46,4 +47,5 @@
|
||||
- [JustAuth与现有用户系统整合](extended/justauth_integrated_with_the_existing_account_system.md)
|
||||
- [Who is using](users.md)
|
||||
- [致谢](thx.md)
|
||||
- [参考文档](references.md)
|
||||
- [更新记录](update.md)
|
||||
|
||||
@@ -31,6 +31,8 @@
|
||||
- 增加飞书授权登录
|
||||
- <img src="https://avatars3.githubusercontent.com/u/20242284?s=88&u=2aeb7576bd61392e9fd94227d2b3048a9aea6f73&v=4" width="20"> · runningzyp : <a href="https://github.com/runningzyp" target="_blank">[Github]</a>
|
||||
- 修改文案错误
|
||||
- <img src="./_media/contributor/f4af112a.png" width="20"> · Spet : <a href="https://github.com/snippet0809" target="_blank">[Github]</a>
|
||||
- 集成阿里云授权登录
|
||||
- 千年等一回,我只为等你...
|
||||
|
||||
ps: 如有遗漏,请告知
|
||||
|
||||
@@ -19,6 +19,13 @@
|
||||
- `stackOverflowKey` Stack Overflow 登陆时需单独提供的key,由**第三方平台颁发**
|
||||
- `agentId` 企业微信登陆时需单独提供该值,由**第三方平台颁发**,为授权方的网页应用ID
|
||||
- `source` JustAuth支持的第三方平台,比如:GITHUB、GITEE等
|
||||
- `uuid` 一般为第三方平台的用户ID。以下几个平台需特别注意:
|
||||
- 钉钉、抖音:`uuid` 为用户的 `unionid`
|
||||
- 微信公众平台登录、京东、酷家乐、美团:`uuid` 为用户的 `openId`
|
||||
- 微信开放平台登录、QQ:`uuid` 为用户的 `openId`,平台支持获取`unionid`, `unionid` 在 `AuthToken` 中(如果支持),在登录完成后,可以通过 `response.getData().getToken().getUnionId()` 获取
|
||||
- Google:`uuid` 为用户的 `sub`,`sub`为Google的所有账户体系中用户唯一的身份标识符,详见:[OpenID Connect](https://developers.google.com/identity/protocols/oauth2/openid-connect)
|
||||
|
||||
注:建议通过`uuid` + `source`的方式唯一确定一个用户,这样可以解决用户身份归属的问题。因为 单个用户ID 在某一平台中是唯一的,但不能保证在所有平台中都是唯一的。
|
||||
|
||||
## 参考资料
|
||||
|
||||
|
||||
@@ -95,6 +95,14 @@ c. 回到应用详情页面,点击【接口加签方式】后面的【设置
|
||||
</dependency>
|
||||
```
|
||||
|
||||
```
|
||||
<dependency>
|
||||
<groupId>com.alipay.sdk</groupId>
|
||||
<artifactId>alipay-sdk-java</artifactId>
|
||||
<version>3.7.4.ALL</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
`${latest.version}`表示当前最新的版本,可以在[这儿](https://github.com/justauth/JustAuth/releases)获取最新的版本信息。
|
||||
|
||||
### 2.2 创建Request
|
||||
|
||||
@@ -0,0 +1,181 @@
|
||||
## 1. 授权流程
|
||||

|
||||
1. 用户通过浏览器登录Web应用。
|
||||
2. Web应用重定向到阿里云OAuth 2.0服务并将URL返回给浏览器。
|
||||
注:如果用户还未登录,则会进一步重定向到阿里云登录服务。
|
||||
3. 用户通过浏览器登录阿里云OAuth 2.0服务并申请授权码。
|
||||
4. 阿里云OAuth 2.0服务重定向到Web应用并返回授权码给浏览器。
|
||||
5. 浏览器通过Web应用使用授权码向阿里云OAuth 2.0服务申请代表用户身份的令牌。
|
||||
6. 阿里云OAuth 2.0服务向Web应用返回令牌。
|
||||
7. Web应用通过获取的令牌向阿里云发起访问API的请求。
|
||||
|
||||
## 2. 配置应用
|
||||
|
||||
### 2.1 创建应用
|
||||
|
||||
1. 云账号登录[RAM控制台](https://ram.console.aliyun.com/?spm=a2c4g.11186623.2.8.46a779b5dxuzTy)。
|
||||
2. 在左侧导航栏,单击OAuth应用管理。
|
||||
3. 单击创建应用。
|
||||
4. 输入应用名称和应用显示名称。
|
||||
5. 选择应用类型。(这儿选择 WebApp 即可)
|
||||
- WebApp: 指基于浏览器交互的网络应用。
|
||||
- NativeApp:指操作系统中运行的本地应用,主要为运行在桌面操作系统或移动操作系统中的应用。
|
||||
- ServerApp:指直接访问阿里云服务,而无需依赖用户登录的应用,目前仅支持基于SCIM协议的用户同步应用。示例请参见[通过SCIM协议将企业内部账号同步到阿里云RAM](https://help.aliyun.com/document_detail/162674.html?spm=a2c4g.11186623.2.9.46a779b5dxuzTy#task-2471389)。
|
||||
6. 根据需要修改访问令牌有效期时长。
|
||||
注:有效期可设置范围为:15分钟至3小时,默认为3600秒。
|
||||
7. 根据需要修改刷新令牌有效期时长。
|
||||
注:有效期可设置范围为:2小时至1年,默认为2592000秒。
|
||||
8. 输入回调地址。
|
||||
9. 单击确定完成应用创建。
|
||||
|
||||
### 2.2 配置应用 OAuth 范围
|
||||
|
||||

|
||||
|
||||
如上,除了默认的 openid 外,再单独增加两条 scope:
|
||||
- aliuid:阿里云颁发的唯一用户标志符
|
||||
- profile:用户的名称等个人信息
|
||||
|
||||
scope 对应获取的用户信息关系表如下:
|
||||
|
||||

|
||||
|
||||
### 2.3 配置密钥
|
||||
|
||||
应用创建完成后,进入应用详情:
|
||||
|
||||

|
||||
|
||||
切换到 “应用密钥” 选项页,创建密钥
|
||||
|
||||

|
||||
|
||||
注:密钥创建完成后记得要保存,因为密钥只能在创建完成后明文显示一次,如丢失或者忘记,请重新创建。
|
||||
|
||||
## 3. 集成JustAuth
|
||||
|
||||
|
||||
### 2.1 引入依赖
|
||||
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>me.zhyd.oauth</groupId>
|
||||
<artifactId>JustAuth</artifactId>
|
||||
<version>${latest.version}</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
`${latest.version}`表示当前最新的版本,可以在[这儿](https://github.com/justauth/JustAuth/releases)获取最新的版本信息。
|
||||
|
||||
### 2.2 创建Request
|
||||
|
||||
```java
|
||||
AuthRequest authRequest = new AuthAliyunRequest(AuthConfig.builder()
|
||||
.clientId("APPID")
|
||||
.clientSecret("应用私钥")
|
||||
.alipayPublicKey("支付宝公钥")
|
||||
.redirectUri("https://www.zhyd.me/oauth/callback/alipay")
|
||||
.build());
|
||||
```
|
||||
|
||||
### 2.3 生成授权地址
|
||||
|
||||
我们可以直接使用以下方式生成第三方平台的授权链接:
|
||||
```java
|
||||
String authorizeUrl = authRequest.authorize(AuthStateUtils.createState());
|
||||
```
|
||||
这个链接我们可以直接后台重定向跳转,也可以返回到前端后,前端控制跳转。前端控制的好处就是,可以将第三方的授权页嵌入到iframe中,适配网站设计。
|
||||
|
||||
|
||||
### 2.4 以上完整代码如下
|
||||
|
||||
```java
|
||||
import me.zhyd.oauth.config.AuthConfig;
|
||||
import me.zhyd.oauth.request.AuthAliyunRequest;
|
||||
import me.zhyd.oauth.model.AuthCallback;
|
||||
import me.zhyd.oauth.request.AuthRequest;
|
||||
import me.zhyd.oauth.utils.AuthStateUtils;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/oauth")
|
||||
public class RestAuthController {
|
||||
|
||||
@RequestMapping("/render")
|
||||
public void renderAuth(HttpServletResponse response) throws IOException {
|
||||
AuthRequest authRequest = getAuthRequest();
|
||||
response.sendRedirect(authRequest.authorize(AuthStateUtils.createState()));
|
||||
}
|
||||
|
||||
@RequestMapping("/callback")
|
||||
public Object login(AuthCallback callback) {
|
||||
AuthRequest authRequest = getAuthRequest();
|
||||
return authRequest.login(callback);
|
||||
}
|
||||
|
||||
private AuthRequest getAuthRequest() {
|
||||
return new AuthAliyunRequest(AuthConfig.builder()
|
||||
.clientId("APPID")
|
||||
.clientSecret("应用私钥")
|
||||
.redirectUri("回调地址")
|
||||
.build());
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 3. 授权结果
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 2000,
|
||||
"msg": null,
|
||||
"data": {
|
||||
"uuid": "lmwxxxw==",
|
||||
"username": "yadong.zhang0415@gmail.com",
|
||||
"nickname": "root",
|
||||
"avatar": null,
|
||||
"blog": null,
|
||||
"company": null,
|
||||
"location": null,
|
||||
"email": null,
|
||||
"remark": null,
|
||||
"gender": "UNKNOWN",
|
||||
"source": "ALIYUN",
|
||||
"token": {
|
||||
"accessToken": "xxxx",
|
||||
"expireIn": 3599,
|
||||
"refreshToken": null,
|
||||
"uid": null,
|
||||
"openId": null,
|
||||
"accessCode": null,
|
||||
"unionId": null,
|
||||
"scope": null,
|
||||
"tokenType": "Bearer",
|
||||
"idToken": "xxxxx",
|
||||
"macAlgorithm": null,
|
||||
"macKey": null,
|
||||
"code": null,
|
||||
"oauthToken": null,
|
||||
"oauthTokenSecret": null,
|
||||
"userId": null,
|
||||
"screenName": null,
|
||||
"oauthCallbackConfirmed": null
|
||||
},
|
||||
"rawUserInfo": {
|
||||
"sub": "lmwtxxxZ9ezw==",
|
||||
"uid": "193xxx",
|
||||
"login_name": "yadong.zhang0415@gmail.com",
|
||||
"requestid": "544effc2-f7ba-4ac7-8af4-da2739e50e04",
|
||||
"name": "root",
|
||||
"bid": "2xxx42",
|
||||
"aid": "193xxx"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -0,0 +1,151 @@
|
||||
## 1. 申请应用
|
||||
|
||||
## 创建 CODING 应用
|
||||
1. 点击【个人设置】->【开放生态】->【创建应用】,注册需要接入 CODING 的应用。
|
||||
|
||||

|
||||
|
||||
2. 在创建应用页面,填写接入的应用信息:
|
||||
|
||||
- 应用名称、应用主页及回调地址为必填项;
|
||||
- 其中回调地址是用户授权后,CODING 回调到应用,并且回传授权码的地址;
|
||||
- 如果没有上传图标将自动生成应用图标。
|
||||
|
||||
填写完毕后,点击【创建应用】。
|
||||
|
||||

|
||||
|
||||
注意:回调地址不支持 `127.0.0.1`、`localhost` 等配置
|
||||
|
||||
3. 应用创建完成后,在应用详情页,会生成 Client ID 和 Client Secret ,保存以便后续认证使用。
|
||||
|
||||

|
||||
|
||||
## 2. 集成JustAuth
|
||||
|
||||
### 2.1 引入依赖
|
||||
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>me.zhyd.oauth</groupId>
|
||||
<artifactId>JustAuth</artifactId>
|
||||
<version>${latest.version}</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
`${latest.version}`表示当前最新的版本,可以在[这儿](https://github.com/justauth/JustAuth/releases)获取最新的版本信息。
|
||||
|
||||
### 2.2 创建Request
|
||||
|
||||
```java
|
||||
AuthRequest authRequest = new AuthTencentCloudRequest(AuthConfig.builder()
|
||||
.clientId("App Key")
|
||||
.clientSecret("App Secret")
|
||||
.redirectUri("授权回调页")
|
||||
.build());
|
||||
```
|
||||
|
||||
### 2.3 生成授权地址
|
||||
|
||||
我们可以直接使用以下方式生成第三方平台的授权链接:
|
||||
```java
|
||||
String authorizeUrl = authRequest.authorize(AuthStateUtils.createState());
|
||||
```
|
||||
这个链接我们可以直接后台重定向跳转,也可以返回到前端后,前端控制跳转。前端控制的好处就是,可以将第三方的授权页嵌入到iframe中,适配网站设计。
|
||||
|
||||
|
||||
### 2.4 以上完整代码如下
|
||||
|
||||
```java
|
||||
import me.zhyd.oauth.config.AuthConfig;
|
||||
import me.zhyd.oauth.request.AuthCodingRequest;
|
||||
import me.zhyd.oauth.model.AuthCallback;
|
||||
import me.zhyd.oauth.model.AuthToken;
|
||||
import me.zhyd.oauth.request.AuthRequest;
|
||||
import me.zhyd.oauth.utils.AuthStateUtils;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/oauth")
|
||||
public class RestAuthController {
|
||||
|
||||
@RequestMapping("/render")
|
||||
public void renderAuth(HttpServletResponse response) throws IOException {
|
||||
AuthRequest authRequest = getAuthRequest();
|
||||
response.sendRedirect(authRequest.authorize(AuthStateUtils.createState()));
|
||||
}
|
||||
|
||||
@RequestMapping("/callback")
|
||||
public Object login(AuthCallback callback) {
|
||||
AuthRequest authRequest = getAuthRequest();
|
||||
return authRequest.login(callback);
|
||||
}
|
||||
|
||||
@RequestMapping("/revoke/{token}")
|
||||
public Object revokeAuth(@PathVariable("token") String token) throws IOException {
|
||||
AuthRequest authRequest = getAuthRequest();
|
||||
return authRequest.revoke(AuthToken.builder().accessToken(token).build());
|
||||
}
|
||||
|
||||
private AuthRequest getAuthRequest() {
|
||||
return new AuthCodingRequest(AuthConfig.builder()
|
||||
.clientId("App Key")
|
||||
.clientSecret("App Secret")
|
||||
.redirectUri("授权回调页")
|
||||
// 比如以“ https://justauth.coding.net/ ”为例,codingGroupName = justauth
|
||||
.codingGroupName("团队名")
|
||||
.build());
|
||||
}
|
||||
}
|
||||
```
|
||||
授权链接访问成功后会看到以下页面内容:
|
||||
|
||||

|
||||
|
||||
## 3. 授权结果
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 2000,
|
||||
"msg": null,
|
||||
"data": {
|
||||
"uuid": "xxx",
|
||||
"username": "yadong.zhang",
|
||||
"nickname": "yadong.zhang",
|
||||
"avatar": "https://coding.net/static/fruit_avatar/Fruit-6.png",
|
||||
"blog": "https://coding.net/u/HNMxPTOFRd",
|
||||
"company": "",
|
||||
"location": "",
|
||||
"email": null,
|
||||
"remark": "",
|
||||
"gender": "FEMALE",
|
||||
"source": "CODING",
|
||||
"token": {
|
||||
"accessToken": "xx",
|
||||
"expireIn": 858292,
|
||||
"refreshToken": "xx",
|
||||
"uid": null,
|
||||
"openId": null,
|
||||
"accessCode": null,
|
||||
"unionId": null,
|
||||
"scope": null,
|
||||
"tokenType": null,
|
||||
"idToken": null,
|
||||
"macAlgorithm": null,
|
||||
"macKey": null,
|
||||
"code": null,
|
||||
"oauthToken": null,
|
||||
"oauthTokenSecret": null,
|
||||
"userId": null,
|
||||
"screenName": null,
|
||||
"oauthCallbackConfirmed": null
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -0,0 +1,104 @@
|
||||
## 1. 申请应用
|
||||
|
||||
参考文章:[twitter三方登录的实现](https://my.oschina.net/u/3361217/blog/1438877),只需关注创建应用部分即可。
|
||||
|
||||
copy以下三个信息:`App ID`、`App Key`和`网站回调域`。
|
||||
|
||||
> 友情提示:twitter现不支持个人用户创建应用
|
||||
|
||||
## 2. 集成JustAuth
|
||||
|
||||
|
||||
### 2.1 引入依赖
|
||||
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>me.zhyd.oauth</groupId>
|
||||
<artifactId>JustAuth</artifactId>
|
||||
<version>${latest.version}</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
`${latest.version}`表示当前最新的版本,可以在[这儿](https://github.com/justauth/JustAuth/releases)获取最新的版本信息。
|
||||
|
||||
### 2.2 创建Request
|
||||
|
||||
```java
|
||||
// 国外平台 目前必须要手动配置代理
|
||||
System.setProperty("proxyPort", "10080");
|
||||
System.setProperty("proxyHost", "127.0.0.1");
|
||||
AuthRequest authRequest = new AuthTwitterRequest(AuthConfig.builder()
|
||||
.clientId("App ID")
|
||||
.clientSecret("App Key")
|
||||
.redirectUri("网站回调域")
|
||||
.build());
|
||||
```
|
||||
|
||||
> 特别注意:所有国外平台都无法直接通过java进行访问API,目前[simple-http](https://github.com/xkcoding/simple-http) Release版本,暂不支持添加代理,所以目前需要手动开启代理。
|
||||
|
||||
代理开启的方式:
|
||||
```java
|
||||
System.setProperty("proxyPort", "10080");
|
||||
System.setProperty("proxyHost", "127.0.0.1");
|
||||
```
|
||||
以上代码可以在声明 `AuthRequest` 时创建,也可以全局执行。
|
||||
|
||||
本地如果支持科学上网,就用自己本地的代理端口即可,如果不支持科学上网,可以去网上找一些免费的代理IP进行测试(请自行操作)。
|
||||
|
||||
### 2.3 生成授权地址
|
||||
|
||||
我们可以直接使用以下方式生成第三方平台的授权链接:
|
||||
```java
|
||||
String authorizeUrl = authRequest.authorize(AuthStateUtils.createState());
|
||||
```
|
||||
这个链接我们可以直接后台重定向跳转,也可以返回到前端后,前端控制跳转。前端控制的好处就是,可以将第三方的授权页嵌入到iframe中,适配网站设计。
|
||||
|
||||
|
||||
### 2.4 以上完整代码如下
|
||||
|
||||
```java
|
||||
import me.zhyd.oauth.config.AuthConfig;
|
||||
import me.zhyd.oauth.request.AuthTwitterRequest;
|
||||
import me.zhyd.oauth.model.AuthCallback;
|
||||
import me.zhyd.oauth.request.AuthRequest;
|
||||
import me.zhyd.oauth.utils.AuthStateUtils;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/oauth")
|
||||
public class RestAuthController {
|
||||
|
||||
@RequestMapping("/render")
|
||||
public void renderAuth(HttpServletResponse response) throws IOException {
|
||||
AuthRequest authRequest = getAuthRequest();
|
||||
response.sendRedirect(authRequest.authorize(AuthStateUtils.createState()));
|
||||
}
|
||||
|
||||
@RequestMapping("/callback")
|
||||
public Object login(AuthCallback callback) {
|
||||
AuthRequest authRequest = getAuthRequest();
|
||||
return authRequest.login(callback);
|
||||
}
|
||||
|
||||
private AuthRequest getAuthRequest() {
|
||||
// 国外平台 目前必须要手动配置代理
|
||||
System.setProperty("proxyPort", "10080");
|
||||
System.setProperty("proxyHost", "127.0.0.1");
|
||||
return new AuthTwitterRequest(AuthConfig.builder()
|
||||
.clientId("App ID")
|
||||
.clientSecret("App Key")
|
||||
.redirectUri("网站回调域")
|
||||
.build());
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 3. 授权结果
|
||||
|
||||
暂无
|
||||
@@ -0,0 +1,47 @@
|
||||
## OAuth 文档
|
||||
|
||||
关于OAuth2相关的内容、原理可以自行参阅以下资料:
|
||||
|
||||
- [The OAuth 2.0 Authorization Framework](https://tools.ietf.org/html/rfc6749)
|
||||
- [OAuth 2.0](https://oauth.net/2/)
|
||||
|
||||
## 第三方平台的API文档
|
||||
|
||||
- <a href="https://gitee.com/api/v5/oauth_doc#list_1" target="_blank">Gitee</a>
|
||||
- <a href="https://developer.github.com/apps/building-oauth-apps/authorizing-oauth-apps/" target="_blank">Github</a>
|
||||
- <a href="https://open.weibo.com/wiki/%E6%8E%88%E6%9D%83%E6%9C%BA%E5%88%B6%E8%AF%B4%E6%98%8E" target="_blank">新浪微博</a>
|
||||
- <a href="https://open-doc.dingtalk.com/microapp/serverapi2/kymkv6" target="_blank">钉钉</a>
|
||||
- <a href="http://developer.baidu.com/wiki/index.php?title=docs/oauth" target="_blank">百度</a>
|
||||
- <a href="https://open.coding.net/references/oauth/" target="_blank">coding</a>
|
||||
- <a href="https://dev.tencent.com/help/doc/faq/b4e5b7aee786/oauth" target="_blank">腾讯云</a>
|
||||
- <a href="https://www.oschina.net/openapi/docs/oauth2_authorize" target="_blank">开源中国</a>
|
||||
- <a href="https://alipay.open.taobao.com/docs/doc.htm?spm=a219a.7629140.0.0.336d4b70GUKXOl&treeId=193&articleId=105809&docType=1" target="_blank">支付宝</a>
|
||||
- <a href="https://wiki.connect.qq.com/%E4%BD%BF%E7%94%A8authorization_code%E8%8E%B7%E5%8F%96access_token" target="_blank">QQ</a>
|
||||
- <a href="https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=open1419316505&token=&lang=zh_CN" target="_blank">微信开放平台</a>
|
||||
- <a href="https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/Wechat_webpage_authorization.html" target="_blank">微信公众平台</a>
|
||||
- <a href="https://open.work.weixin.qq.com/api/doc#90000/90135/90664" target="_blank">企业微信</a>
|
||||
- <a href="https://open.taobao.com/doc.htm?spm=a219a.7386797.0.0.4e00669acnkQy6&source=search&docId=105590&docType=1" target="_blank">淘宝</a>
|
||||
- <a href="https://developers.google.com/identity/protocols/OpenIDConnect" target="_blank">Google</a>
|
||||
- <a href="https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow" target="_blank">Facebook</a>
|
||||
- <a href="https://open.douyin.com/platform/doc/OpenAPI-oauth2" target="_blank">抖音</a>
|
||||
- <a href="https://docs.microsoft.com/zh-cn/linkedin/shared/authentication/authorization-code-flow?context=linkedin/context" target="_blank">领英</a>
|
||||
- <a href="https://docs.microsoft.com/zh-cn/graph/auth-v2-user" target="_blank">微软</a>
|
||||
- <a href="https://dev.mi.com/console/doc/detail?pId=711" target="_blank">小米</a>
|
||||
- <a href="https://open.mp.toutiao.com/#/resource?_k=y7mfgk" target="_blank">头条</a>
|
||||
- <a href="https://docs.teambition.com/" target="_blank">Teambition</a>
|
||||
- <a href="http://open.renren.com/wiki/OAuth2.0" target="_blank">人人</a>
|
||||
- <a href="https://developers.pinterest.com/docs/api/overview/?" target="_blank">Pinterest</a>
|
||||
- <a href="https://api.stackexchange.com/docs/authentication" target="_blank">StackOverflow</a>
|
||||
- <a href="https://developer.huawei.com/consumer/cn/devservice/doc/30101" target="_blank">华为</a>
|
||||
- <a href="https://open.kujiale.com/open/apps/2/docs?doc_id=95" target="_blank">酷家乐</a>
|
||||
- <a href="https://docs.gitlab.com/ee/api/oauth2.html" target="_blank">Gitlab</a>
|
||||
- <a href="http://open.waimai.meituan.com/openapi_docs/oauth/" target="_blank">美团</a>
|
||||
- <a href="https://open.shop.ele.me/openapi/documents/khd001" target="_blank">饿了么</a>
|
||||
- <a href="https://developer.twitter.com/en/docs/basics/authentication/guides/log-in-with-twitter" target="_blank">推特</a>
|
||||
- <a href="https://developer.twitter.com/en/docs/tweets/data-dictionary/overview/user-object" target="_blank">用户信息</a>
|
||||
- <a href="https://developer.twitter.com/en/docs/basics/response-codes" target="_blank">响应码</a>
|
||||
- <a href="https://developer.twitter.com/en/docs/basics/apps/guides/callback-urls" target="_blank">Callback Urls规则</a>
|
||||
- <a href="https://help.aliyun.com/document_detail/93696.html?spm=a2c4g.11186623.6.656.1a764138vhg4gr" target="_blank">阿里云</a>
|
||||
- [Web应用登录阿里云](https://help.aliyun.com/document_detail/93696.html?spm=a2c4g.11186623.6.656.1a764138vhg4gr)
|
||||
- [通过OIDC获取用户信息](https://help.aliyun.com/document_detail/93698.html?spm=a2c4g.11186623.6.658.537dd19eE1eEJh)
|
||||
- <a href="https://open.jd.com/home/home#/doc/common?listId=880" target="_blank">京东·宙斯</a>
|
||||
@@ -13,3 +13,6 @@
|
||||
|
||||
<div style="clear: both;"></div>
|
||||
|
||||
<a href="https://www.producthunt.com/posts/justauth?utm_source=badge-featured&utm_medium=badge&utm_souce=badge-justauth" target="_blank"><img src="https://api.producthunt.com/widgets/embed-image/v1/featured.svg?post_id=196886&theme=dark" alt="JustAuth - Login, so easy! | Product Hunt Embed" style="width: 250px; height: 54px;" width="250px" height="54px" /></a>
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,68 @@
|
||||
## 1.15.5
|
||||
### 2020/06/24
|
||||
- BUG
|
||||
- 解决 `Microsoft` 授权失败的 BUG
|
||||
- 解决 `Coding` 个人账号授权失败的 BUG(目前只能使用团队模式进行授权,需要传入团队名,参考`AuthConfig#codingGroupName`)
|
||||
- 解决 `AuthLinkedinRequest#getAvatar` NPE 的问题。(领英用户没有头像时,原代码会报 NPE)
|
||||
- 解决抖音登录获取用户地址异常的问题。
|
||||
- 解决人人网登录时 token 中带有 `|` 引起的异常,[Gitee!15](https://gitee.com/yadong.zhang/JustAuth/pulls/15)
|
||||
- 新增
|
||||
- 支持阿里云授权登录,[Github#81](https://github.com/justauth/JustAuth/pull/81)
|
||||
- AuthUser 中新增 `rawUserInfo`,用来存放第三方平台返回的原始用户数据。注:淘宝平台的`rawUserInfo`为一个空 JSON
|
||||
- 支持 Http 级的代理配置,使用方式:
|
||||
```java
|
||||
new AuthGoogleRequest(AuthConfig.builder()
|
||||
.clientId("")
|
||||
.clientSecret("")
|
||||
.redirectUri("http://127.0.0.1:8443/oauth/callback/google")
|
||||
// 针对国外平台配置代理
|
||||
.httpConfig(HttpConfig.builder()
|
||||
.timeout(15000)
|
||||
.proxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress("127.0.0.1", 10080)))
|
||||
.build())
|
||||
.build());
|
||||
```
|
||||
- 修改
|
||||
- 升级 [simple-http](https://github.com/xkcoding/simple-http) 到 `v1.0.2`
|
||||
- 升级 `fastjson` 到 `v1.2.71`
|
||||
- 删除
|
||||
- :boom: 删除**腾讯云登录**。coding 已并入 腾讯云,因此只保留 coding 登录 :boom:
|
||||
- 文档
|
||||
- 新增 [Coding登录](oauth/coding.md)文档
|
||||
- 完善 [支付宝登录](oauth/alipay.md)文档
|
||||
- 完善 [贡献者名单](contributors.md)文档
|
||||
- 完善 [参考文档](references.md)文档
|
||||
- PR
|
||||
- 合并 [Gitee!17](https://gitee.com/yadong.zhang/JustAuth/pulls/17)
|
||||
- 合并 [Gitee!15](https://gitee.com/yadong.zhang/JustAuth/pulls/15)
|
||||
- 合并 [Github#81](https://github.com/justauth/JustAuth/pull/81)
|
||||
- Issues
|
||||
- 解决 [Github#80](https://github.com/justauth/JustAuth/issues/80)
|
||||
- 解决 [Github#75](https://github.com/justauth/JustAuth/issues/75)
|
||||
|
||||
## 1.15.4-alpha
|
||||
### 2020/05/13
|
||||
- 修复
|
||||
- 解决 Twitter 授权失败的BUG
|
||||
- 文档
|
||||
- 完善 [https://docs.justauth.whnb.wang](https://docs.justauth.whnb.wang/) 的404引导页内容
|
||||
- 增加名词解释: `uuid`
|
||||
- 补充 [Q&A](Q&A.md)
|
||||
- 新增 [参考文档](references.md),包含 OAuth 授权和第三方平台的API文档等内容
|
||||
- 新增 [推特登录](oauth/twitter.md) 的说明文档
|
||||
|
||||
> 特别注意:所有国外平台都无法直接通过java进行访问API,目前[simple-http](https://github.com/xkcoding/simple-http) Release版本,暂不支持添加代理,所以目前需要手动开启代理。
|
||||
|
||||
代理开启的方式:
|
||||
```java
|
||||
System.setProperty("proxyPort", "10080");
|
||||
System.setProperty("proxyHost", "127.0.0.1");
|
||||
```
|
||||
以上代码可以在声明 `AuthRequest` 时创建,也可以全局执行。
|
||||
|
||||
本地如果支持科学上网,就用自己本地的代理端口即可,如果不支持科学上网,可以去网上找一些免费的代理IP进行测试(请自行操作)。
|
||||
|
||||
|
||||
## 1.15.2-alpha
|
||||
### 2020/05/10
|
||||
- 修改
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>me.zhyd.oauth</groupId>
|
||||
<artifactId>JustAuth</artifactId>
|
||||
<version>1.15.2-alpha</version>
|
||||
<version>1.15.5</version>
|
||||
|
||||
<name>JustAuth</name>
|
||||
<url>https://gitee.com/yadong.zhang/JustAuth</url>
|
||||
@@ -60,10 +60,10 @@
|
||||
<maven-surefire-version>2.20</maven-surefire-version>
|
||||
<maven-gpg-version>1.6</maven-gpg-version>
|
||||
<maven.test.skip>false</maven.test.skip>
|
||||
<simple-http.version>1.0.1</simple-http.version>
|
||||
<simple-http.version>1.0.2</simple-http.version>
|
||||
<lombok-version>1.18.10</lombok-version>
|
||||
<junit-version>4.11</junit-version>
|
||||
<fastjson-version>1.2.68</fastjson-version>
|
||||
<fastjson-version>1.2.71</fastjson-version>
|
||||
<alipay-sdk-version>4.8.10.ALL</alipay-sdk-version>
|
||||
<jacoco-version>0.8.2</jacoco-version>
|
||||
</properties>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package me.zhyd.oauth.config;
|
||||
|
||||
import com.xkcoding.http.config.HttpConfig;
|
||||
import lombok.*;
|
||||
|
||||
/**
|
||||
@@ -59,4 +60,23 @@ public class AuthConfig {
|
||||
* @since 1.10.0
|
||||
*/
|
||||
private String agentId;
|
||||
|
||||
/**
|
||||
* 使用 Coding 登录时,需要传该值。
|
||||
*
|
||||
* 团队域名前缀,比如以“ https://justauth.coding.net/ ”为例,{@code codingGroupName} = justauth
|
||||
*
|
||||
* @since 1.15.5
|
||||
*/
|
||||
private String codingGroupName;
|
||||
|
||||
/**
|
||||
* 针对国外服务可以单独设置代理
|
||||
* HttpConfig config = new HttpConfig();
|
||||
* config.setProxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress("127.0.0.1", 10080)));
|
||||
* config.setTimeout(15000);
|
||||
*
|
||||
* @since 1.15.5
|
||||
*/
|
||||
private HttpConfig httpConfig;
|
||||
}
|
||||
|
||||
@@ -140,41 +140,25 @@ public enum AuthDefaultSource implements AuthSource {
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Coding
|
||||
* Coding,
|
||||
*
|
||||
* 参考 https://help.coding.net/docs/project/open/oauth.html#%E7%94%A8%E6%88%B7%E6%8E%88%E6%9D%83 中的说明,
|
||||
* 新版的 coding API 地址需要传入用户团队名,这儿使用动态参数,方便在 request 中使用
|
||||
*/
|
||||
CODING {
|
||||
@Override
|
||||
public String authorize() {
|
||||
return "https://coding.net/oauth_authorize.html";
|
||||
return "https://%s.coding.net/oauth_authorize.html";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String accessToken() {
|
||||
return "https://coding.net/api/oauth/access_token";
|
||||
return "https://%s.coding.net/api/oauth/access_token";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String userInfo() {
|
||||
return "https://coding.net/api/account/current_user";
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 腾讯云开发者平台(coding升级后就变成腾讯云开发者平台了)
|
||||
*/
|
||||
TENCENT_CLOUD {
|
||||
@Override
|
||||
public String authorize() {
|
||||
return "https://dev.tencent.com/oauth_authorize.html";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String accessToken() {
|
||||
return "https://dev.tencent.com/api/oauth/access_token";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String userInfo() {
|
||||
return "https://dev.tencent.com/api/account/current_user";
|
||||
return "https://%s.coding.net/api/account/current_user";
|
||||
}
|
||||
},
|
||||
/**
|
||||
@@ -765,7 +749,7 @@ public enum AuthDefaultSource implements AuthSource {
|
||||
|
||||
@Override
|
||||
public String accessToken() {
|
||||
return "https://open-oauth.jd.com/oauth2/access_token";
|
||||
return "https://open-oauth.jd.com/oauth2/access_token";
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -777,5 +761,31 @@ public enum AuthDefaultSource implements AuthSource {
|
||||
public String refresh() {
|
||||
return "https://open-oauth.jd.com/oauth2/refresh_token";
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 阿里云
|
||||
*/
|
||||
ALIYUN {
|
||||
@Override
|
||||
public String authorize() {
|
||||
return "https://signin.aliyun.com/oauth2/v1/auth";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String accessToken() {
|
||||
return "https://oauth.aliyun.com/v1/token";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String userInfo() {
|
||||
return "https://oauth.aliyun.com/v1/userinfo";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String refresh() {
|
||||
return "https://oauth.aliyun.com/v1/token";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -48,12 +48,13 @@ public class AuthCallback implements Serializable {
|
||||
*
|
||||
* @since 1.13.0
|
||||
*/
|
||||
private String oauthToken;
|
||||
private String oauth_token;
|
||||
|
||||
/**
|
||||
* Twitter回调后返回的oauth_verifier
|
||||
*
|
||||
* @since 1.13.0
|
||||
*/
|
||||
private String oauthVerifier;
|
||||
private String oauth_verifier;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package me.zhyd.oauth.model;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.*;
|
||||
import me.zhyd.oauth.enums.AuthUserGender;
|
||||
import java.io.Serializable;
|
||||
@@ -17,7 +18,7 @@ import java.io.Serializable;
|
||||
@AllArgsConstructor
|
||||
public class AuthUser implements Serializable {
|
||||
/**
|
||||
* 用户第三方系统的唯一id。在调用方集成改组件时,可以用uuid + source唯一确定一个用户
|
||||
* 用户第三方系统的唯一id。在调用方集成该组件时,可以用uuid + source唯一确定一个用户
|
||||
*
|
||||
* @since 1.3.3
|
||||
*/
|
||||
@@ -66,5 +67,9 @@ public class AuthUser implements Serializable {
|
||||
* 用户授权的token信息
|
||||
*/
|
||||
private AuthToken token;
|
||||
/**
|
||||
* 第三方平台返回的原始用户信息
|
||||
*/
|
||||
private JSONObject rawUserInfo;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package me.zhyd.oauth.request;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alipay.api.AlipayApiException;
|
||||
import com.alipay.api.AlipayClient;
|
||||
import com.alipay.api.DefaultAlipayClient;
|
||||
@@ -80,6 +81,7 @@ public class AuthAlipayRequest extends AuthDefaultRequest {
|
||||
String location = String.format("%s %s", StringUtils.isEmpty(province) ? "" : province, StringUtils.isEmpty(city) ? "" : city);
|
||||
|
||||
return AuthUser.builder()
|
||||
.rawUserInfo(JSONObject.parseObject(JSONObject.toJSONString(response)))
|
||||
.uuid(response.getUserId())
|
||||
.username(StringUtils.isEmpty(response.getUserName()) ? response.getNickName() : response.getUserName())
|
||||
.nickname(response.getNickName())
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
package me.zhyd.oauth.request;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import me.zhyd.oauth.cache.AuthStateCache;
|
||||
import me.zhyd.oauth.config.AuthConfig;
|
||||
import me.zhyd.oauth.config.AuthDefaultSource;
|
||||
import me.zhyd.oauth.enums.AuthUserGender;
|
||||
import me.zhyd.oauth.model.AuthCallback;
|
||||
import me.zhyd.oauth.model.AuthToken;
|
||||
import me.zhyd.oauth.model.AuthUser;
|
||||
import me.zhyd.oauth.utils.UrlBuilder;
|
||||
|
||||
/**
|
||||
* 阿里云登录
|
||||
*
|
||||
* @author snippet0809 (https://github.com/snippet0809)
|
||||
* @since 1.15.5
|
||||
*/
|
||||
public class AuthAliyunRequest extends AuthDefaultRequest {
|
||||
|
||||
public AuthAliyunRequest(AuthConfig config) {
|
||||
super(config, AuthDefaultSource.ALIYUN);
|
||||
}
|
||||
|
||||
public AuthAliyunRequest(AuthConfig config, AuthStateCache authStateCache) {
|
||||
super(config, AuthDefaultSource.ALIYUN, authStateCache);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AuthToken getAccessToken(AuthCallback authCallback) {
|
||||
String response = doPostAuthorizationCode(authCallback.getCode());
|
||||
JSONObject accessTokenObject = JSONObject.parseObject(response);
|
||||
return AuthToken.builder()
|
||||
.accessToken(accessTokenObject.getString("access_token"))
|
||||
.expireIn(accessTokenObject.getIntValue("expires_in"))
|
||||
.tokenType(accessTokenObject.getString("token_type"))
|
||||
.idToken(accessTokenObject.getString("id_token"))
|
||||
.refreshToken(accessTokenObject.getString("refresh_token"))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AuthUser getUserInfo(AuthToken authToken) {
|
||||
String userInfo = doGetUserInfo(authToken);
|
||||
JSONObject object = JSONObject.parseObject(userInfo);
|
||||
return AuthUser.builder()
|
||||
.rawUserInfo(object)
|
||||
.uuid(object.getString("sub"))
|
||||
.username(object.getString("login_name"))
|
||||
.nickname(object.getString("name"))
|
||||
.gender(AuthUserGender.UNKNOWN)
|
||||
.token(authToken)
|
||||
.source(source.toString())
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package me.zhyd.oauth.request;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.xkcoding.http.HttpUtil;
|
||||
import me.zhyd.oauth.utils.HttpUtils;
|
||||
import me.zhyd.oauth.cache.AuthStateCache;
|
||||
import me.zhyd.oauth.config.AuthConfig;
|
||||
import me.zhyd.oauth.config.AuthDefaultSource;
|
||||
@@ -37,13 +37,21 @@ public class AuthBaiduRequest extends AuthDefaultRequest {
|
||||
return getAuthToken(response);
|
||||
}
|
||||
|
||||
/**
|
||||
* https://openapi.baidu.com/rest/2.0/passport/users/getInfo?access_token=121.c86e87cc0828cc1dabb8faee540531d4.YsUIAWvYbgqVni1VhkgKgyLh8nEyELbDOEZs_OA.OgDgmA
|
||||
* https://openapi.baidu.com/rest/2.0/passport/users/getInfo?access_token=121.2907d9facf9fb97adf7287fa75496eda.Y3NSjR3-3HKt1RgT0HEl7GgxRXT5gOOVdngXezY.OcC_7g
|
||||
* 新旧应用返回的用户信息不一致
|
||||
* @param authToken token信息
|
||||
* @return AuthUser
|
||||
*/
|
||||
@Override
|
||||
protected AuthUser getUserInfo(AuthToken authToken) {
|
||||
String userInfo = doGetUserInfo(authToken);
|
||||
JSONObject object = JSONObject.parseObject(userInfo);
|
||||
this.checkResponse(object);
|
||||
return AuthUser.builder()
|
||||
.uuid(object.getString("userid"))
|
||||
.rawUserInfo(object)
|
||||
.uuid(object.containsKey("userid") ? object.getString("userid") : object.getString("openid"))
|
||||
.username(object.getString("username"))
|
||||
.nickname(object.getString("username"))
|
||||
.avatar(getAvatar(object))
|
||||
@@ -77,7 +85,7 @@ public class AuthBaiduRequest extends AuthDefaultRequest {
|
||||
.queryParam("client_id", this.config.getClientId())
|
||||
.queryParam("client_secret", this.config.getClientSecret())
|
||||
.build();
|
||||
String response = HttpUtil.get(refreshUrl);
|
||||
String response = new HttpUtils(config.getHttpConfig()).get(refreshUrl);
|
||||
return AuthResponse.builder()
|
||||
.code(AuthResponseStatus.SUCCESS.getCode())
|
||||
.data(this.getAuthToken(response))
|
||||
|
||||
@@ -47,10 +47,11 @@ public class AuthCodingRequest extends AuthDefaultRequest {
|
||||
|
||||
object = object.getJSONObject("data");
|
||||
return AuthUser.builder()
|
||||
.rawUserInfo(object)
|
||||
.uuid(object.getString("id"))
|
||||
.username(object.getString("name"))
|
||||
.avatar("https://coding.net/" + object.getString("avatar"))
|
||||
.blog("https://coding.net/" + object.getString("path"))
|
||||
.avatar("https://coding.net" + object.getString("avatar"))
|
||||
.blog("https://coding.net" + object.getString("path"))
|
||||
.nickname(object.getString("name"))
|
||||
.company(object.getString("company"))
|
||||
.location(object.getString("location"))
|
||||
@@ -82,7 +83,7 @@ public class AuthCodingRequest extends AuthDefaultRequest {
|
||||
*/
|
||||
@Override
|
||||
public String authorize(String state) {
|
||||
return UrlBuilder.fromBaseUrl(source.authorize())
|
||||
return UrlBuilder.fromBaseUrl(String.format(source.authorize(), config.getCodingGroupName()))
|
||||
.queryParam("response_type", "code")
|
||||
.queryParam("client_id", config.getClientId())
|
||||
.queryParam("redirect_uri", config.getRedirectUri())
|
||||
@@ -90,4 +91,33 @@ public class AuthCodingRequest extends AuthDefaultRequest {
|
||||
.queryParam("state", getRealState(state))
|
||||
.build();
|
||||
}
|
||||
/**
|
||||
* 返回获取accessToken的url
|
||||
*
|
||||
* @param code 授权码
|
||||
* @return 返回获取accessToken的url
|
||||
*/
|
||||
@Override
|
||||
public String accessTokenUrl(String code) {
|
||||
return UrlBuilder.fromBaseUrl(String.format(source.accessToken(), config.getCodingGroupName()))
|
||||
.queryParam("code", code)
|
||||
.queryParam("client_id", config.getClientId())
|
||||
.queryParam("client_secret", config.getClientSecret())
|
||||
.queryParam("grant_type", "authorization_code")
|
||||
.queryParam("redirect_uri", config.getRedirectUri())
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回获取userInfo的url
|
||||
*
|
||||
* @param authToken token
|
||||
* @return 返回获取userInfo的url
|
||||
*/
|
||||
@Override
|
||||
public String userInfoUrl(AuthToken authToken) {
|
||||
return UrlBuilder.fromBaseUrl(String.format(source.userInfo(), config.getCodingGroupName()))
|
||||
.queryParam("access_token", authToken.getAccessToken())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ public class AuthCsdnRequest extends AuthDefaultRequest {
|
||||
JSONObject object = JSONObject.parseObject(response);
|
||||
this.checkResponse(object);
|
||||
return AuthUser.builder()
|
||||
.rawUserInfo(object)
|
||||
.uuid(object.getString("username"))
|
||||
.username(object.getString("username"))
|
||||
.remark(object.getString("description"))
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package me.zhyd.oauth.request;
|
||||
|
||||
import com.xkcoding.http.HttpUtil;
|
||||
import me.zhyd.oauth.utils.HttpUtils;
|
||||
import me.zhyd.oauth.cache.AuthDefaultStateCache;
|
||||
import me.zhyd.oauth.cache.AuthStateCache;
|
||||
import me.zhyd.oauth.config.AuthConfig;
|
||||
@@ -210,7 +210,7 @@ public abstract class AuthDefaultRequest implements AuthRequest {
|
||||
* @return Response
|
||||
*/
|
||||
protected String doPostAuthorizationCode(String code) {
|
||||
return HttpUtil.post(accessTokenUrl(code));
|
||||
return new HttpUtils(config.getHttpConfig()).post(accessTokenUrl(code));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -220,7 +220,7 @@ public abstract class AuthDefaultRequest implements AuthRequest {
|
||||
* @return Response
|
||||
*/
|
||||
protected String doGetAuthorizationCode(String code) {
|
||||
return HttpUtil.get(accessTokenUrl(code));
|
||||
return new HttpUtils(config.getHttpConfig()).get(accessTokenUrl(code));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -231,7 +231,7 @@ public abstract class AuthDefaultRequest implements AuthRequest {
|
||||
*/
|
||||
@Deprecated
|
||||
protected String doPostUserInfo(AuthToken authToken) {
|
||||
return HttpUtil.post(userInfoUrl(authToken));
|
||||
return new HttpUtils(config.getHttpConfig()).post(userInfoUrl(authToken));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -241,7 +241,7 @@ public abstract class AuthDefaultRequest implements AuthRequest {
|
||||
* @return Response
|
||||
*/
|
||||
protected String doGetUserInfo(AuthToken authToken) {
|
||||
return HttpUtil.get(userInfoUrl(authToken));
|
||||
return new HttpUtils(config.getHttpConfig()).get(userInfoUrl(authToken));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -252,7 +252,7 @@ public abstract class AuthDefaultRequest implements AuthRequest {
|
||||
*/
|
||||
@Deprecated
|
||||
protected String doPostRevoke(AuthToken authToken) {
|
||||
return HttpUtil.post(revokeUrl(authToken));
|
||||
return new HttpUtils(config.getHttpConfig()).post(revokeUrl(authToken));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -262,7 +262,7 @@ public abstract class AuthDefaultRequest implements AuthRequest {
|
||||
* @return Response
|
||||
*/
|
||||
protected String doGetRevoke(AuthToken authToken) {
|
||||
return HttpUtil.get(revokeUrl(authToken));
|
||||
return new HttpUtils(config.getHttpConfig()).get(revokeUrl(authToken));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package me.zhyd.oauth.request;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.xkcoding.http.HttpUtil;
|
||||
import me.zhyd.oauth.utils.HttpUtils;
|
||||
import me.zhyd.oauth.cache.AuthStateCache;
|
||||
import me.zhyd.oauth.config.AuthConfig;
|
||||
import me.zhyd.oauth.config.AuthDefaultSource;
|
||||
@@ -40,7 +40,7 @@ public class AuthDingTalkRequest extends AuthDefaultRequest {
|
||||
String code = authToken.getAccessCode();
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("tmp_auth_code", code);
|
||||
String response = HttpUtil.post(userInfoUrl(authToken), param.toJSONString());
|
||||
String response = new HttpUtils(config.getHttpConfig()).post(userInfoUrl(authToken), param.toJSONString());
|
||||
JSONObject object = JSON.parseObject(response);
|
||||
if (object.getIntValue("errcode") != 0) {
|
||||
throw new AuthException(object.getString("errmsg"));
|
||||
@@ -51,6 +51,7 @@ public class AuthDingTalkRequest extends AuthDefaultRequest {
|
||||
.unionId(object.getString("unionid"))
|
||||
.build();
|
||||
return AuthUser.builder()
|
||||
.rawUserInfo(object)
|
||||
.uuid(object.getString("unionid"))
|
||||
.nickname(object.getString("nick"))
|
||||
.username(object.getString("nick"))
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package me.zhyd.oauth.request;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.xkcoding.http.HttpUtil;
|
||||
import me.zhyd.oauth.utils.HttpUtils;
|
||||
import me.zhyd.oauth.cache.AuthStateCache;
|
||||
import me.zhyd.oauth.config.AuthConfig;
|
||||
import me.zhyd.oauth.config.AuthDefaultSource;
|
||||
@@ -41,15 +41,16 @@ public class AuthDouyinRequest extends AuthDefaultRequest {
|
||||
String response = doGetUserInfo(authToken);
|
||||
JSONObject userInfoObject = JSONObject.parseObject(response);
|
||||
this.checkResponse(userInfoObject);
|
||||
JSONObject dataObj = userInfoObject.getJSONObject("data");
|
||||
JSONObject object = userInfoObject.getJSONObject("data");
|
||||
return AuthUser.builder()
|
||||
.uuid(dataObj.getString("union_id"))
|
||||
.username(dataObj.getString("nickname"))
|
||||
.nickname(dataObj.getString("nickname"))
|
||||
.avatar(dataObj.getString("avatar"))
|
||||
.remark(dataObj.getString("description"))
|
||||
.gender(AuthUserGender.getRealGender(dataObj.getString("gender")))
|
||||
.location(String.format("%s %s %s", dataObj.getString("country"), dataObj.getString("province"), dataObj.getString("city")))
|
||||
.rawUserInfo(object)
|
||||
.uuid(object.getString("union_id"))
|
||||
.username(object.getString("nickname"))
|
||||
.nickname(object.getString("nickname"))
|
||||
.avatar(object.getString("avatar"))
|
||||
.remark(object.getString("description"))
|
||||
.gender(AuthUserGender.getRealGender(object.getString("gender")))
|
||||
.location(String.format("%s %s %s", object.getString("country"), object.getString("province"), object.getString("city")))
|
||||
.token(authToken)
|
||||
.source(source.toString())
|
||||
.build();
|
||||
@@ -84,7 +85,7 @@ public class AuthDouyinRequest extends AuthDefaultRequest {
|
||||
* @return token对象
|
||||
*/
|
||||
private AuthToken getToken(String accessTokenUrl) {
|
||||
String response = HttpUtil.post(accessTokenUrl);
|
||||
String response = new HttpUtils(config.getHttpConfig()).post(accessTokenUrl);
|
||||
JSONObject object = JSONObject.parseObject(response);
|
||||
this.checkResponse(object);
|
||||
JSONObject dataObj = object.getJSONObject("data");
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package me.zhyd.oauth.request;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.xkcoding.http.HttpUtil;
|
||||
import me.zhyd.oauth.utils.HttpUtils;
|
||||
import com.xkcoding.http.constants.Constants;
|
||||
import com.xkcoding.http.support.HttpHeader;
|
||||
import me.zhyd.oauth.cache.AuthStateCache;
|
||||
@@ -52,7 +52,7 @@ public class AuthElemeRequest extends AuthDefaultRequest {
|
||||
form.put("grant_type", "authorization_code");
|
||||
|
||||
HttpHeader httpHeader = this.buildHeader(CONTENT_TYPE_FORM, this.getRequestId(), true);
|
||||
String response = HttpUtil.post(source.accessToken(), form, httpHeader, false);
|
||||
String response = new HttpUtils(config.getHttpConfig()).post(source.accessToken(), form, httpHeader, false);
|
||||
JSONObject object = JSONObject.parseObject(response);
|
||||
|
||||
this.checkResponse(object);
|
||||
@@ -91,7 +91,7 @@ public class AuthElemeRequest extends AuthDefaultRequest {
|
||||
paramsMap.put("signature", signature);
|
||||
|
||||
HttpHeader httpHeader = this.buildHeader(CONTENT_TYPE_JSON, requestId, false);
|
||||
String response = HttpUtil.post(source.userInfo(), JSONObject.toJSONString(paramsMap), httpHeader);
|
||||
String response = new HttpUtils(config.getHttpConfig()).post(source.userInfo(), JSONObject.toJSONString(paramsMap), httpHeader);
|
||||
|
||||
JSONObject object = JSONObject.parseObject(response);
|
||||
|
||||
@@ -106,6 +106,7 @@ public class AuthElemeRequest extends AuthDefaultRequest {
|
||||
JSONObject result = object.getJSONObject("result");
|
||||
|
||||
return AuthUser.builder()
|
||||
.rawUserInfo(result)
|
||||
.uuid(result.getString("userId"))
|
||||
.username(result.getString("userName"))
|
||||
.nickname(result.getString("userName"))
|
||||
@@ -122,7 +123,7 @@ public class AuthElemeRequest extends AuthDefaultRequest {
|
||||
form.put("grant_type", "refresh_token");
|
||||
|
||||
HttpHeader httpHeader = this.buildHeader(CONTENT_TYPE_FORM, this.getRequestId(), true);
|
||||
String response = HttpUtil.post(source.refresh(), form, httpHeader, false);
|
||||
String response = new HttpUtils(config.getHttpConfig()).post(source.refresh(), form, httpHeader, false);
|
||||
|
||||
JSONObject object = JSONObject.parseObject(response);
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@ public class AuthFacebookRequest extends AuthDefaultRequest {
|
||||
JSONObject object = JSONObject.parseObject(userInfo);
|
||||
this.checkResponse(object);
|
||||
return AuthUser.builder()
|
||||
.rawUserInfo(object)
|
||||
.uuid(object.getString("id"))
|
||||
.username(object.getString("name"))
|
||||
.nickname(object.getString("name"))
|
||||
|
||||
@@ -2,7 +2,6 @@ package me.zhyd.oauth.request;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.xkcoding.http.HttpUtil;
|
||||
import com.xkcoding.http.support.HttpHeader;
|
||||
import me.zhyd.oauth.config.AuthConfig;
|
||||
import me.zhyd.oauth.config.AuthDefaultSource;
|
||||
@@ -13,6 +12,7 @@ import me.zhyd.oauth.model.AuthResponse;
|
||||
import me.zhyd.oauth.model.AuthToken;
|
||||
import me.zhyd.oauth.model.AuthUser;
|
||||
import me.zhyd.oauth.utils.GlobalAuthUtils;
|
||||
import me.zhyd.oauth.utils.HttpUtils;
|
||||
import me.zhyd.oauth.utils.UrlBuilder;
|
||||
|
||||
/**
|
||||
@@ -36,7 +36,7 @@ public class AuthFeishuRequest extends AuthDefaultRequest {
|
||||
requestObject.put("app_secret", config.getClientSecret());
|
||||
requestObject.put("grant_type", "authorization_code");
|
||||
requestObject.put("code", authCallback.getCode());
|
||||
String response = HttpUtil.post(source.accessToken(), requestObject.toJSONString(), new HttpHeader()
|
||||
String response = new HttpUtils(config.getHttpConfig()).post(source.accessToken(), requestObject.toJSONString(), new HttpHeader()
|
||||
.add("Content-Type", "application/json"));
|
||||
JSONObject jsonObject = JSON.parseObject(response);
|
||||
this.checkResponse(jsonObject);
|
||||
@@ -53,14 +53,15 @@ public class AuthFeishuRequest extends AuthDefaultRequest {
|
||||
@Override
|
||||
protected AuthUser getUserInfo(AuthToken authToken) {
|
||||
String accessToken = authToken.getAccessToken();
|
||||
String response = HttpUtil.get(source.userInfo(), null, new HttpHeader()
|
||||
String response = new HttpUtils(config.getHttpConfig()).get(source.userInfo(), null, new HttpHeader()
|
||||
.add("Content-Type", "application/json")
|
||||
.add("Authorization", "Bearer " + accessToken), false);
|
||||
JSONObject jsonObject = JSON.parseObject(response);
|
||||
JSONObject object = JSON.parseObject(response);
|
||||
return AuthUser.builder()
|
||||
.avatar(jsonObject.getString("AvatarUrl"))
|
||||
.username(jsonObject.getString("Mobile"))
|
||||
.email(jsonObject.getString("Email"))
|
||||
.rawUserInfo(object)
|
||||
.avatar(object.getString("AvatarUrl"))
|
||||
.username(object.getString("Mobile"))
|
||||
.email(object.getString("Email"))
|
||||
.nickname("Name")
|
||||
.build();
|
||||
}
|
||||
@@ -72,7 +73,7 @@ public class AuthFeishuRequest extends AuthDefaultRequest {
|
||||
requestObject.put("app_secret", config.getClientSecret());
|
||||
requestObject.put("grant_type", "refresh_token");
|
||||
requestObject.put("refresh_token", authToken.getRefreshToken());
|
||||
String response = HttpUtil.post(source.refresh(), requestObject.toJSONString(), new HttpHeader()
|
||||
String response = new HttpUtils(config.getHttpConfig()).post(source.refresh(), requestObject.toJSONString(), new HttpHeader()
|
||||
.add("Content-Type", "application/json"));
|
||||
JSONObject jsonObject = JSON.parseObject(response);
|
||||
this.checkResponse(jsonObject);
|
||||
|
||||
@@ -46,6 +46,7 @@ public class AuthGiteeRequest extends AuthDefaultRequest {
|
||||
JSONObject object = JSONObject.parseObject(userInfo);
|
||||
this.checkResponse(object);
|
||||
return AuthUser.builder()
|
||||
.rawUserInfo(object)
|
||||
.uuid(object.getString("id"))
|
||||
.username(object.getString("login"))
|
||||
.avatar(object.getString("avatar_url"))
|
||||
|
||||
@@ -51,6 +51,7 @@ public class AuthGithubRequest extends AuthDefaultRequest {
|
||||
this.checkResponse(object.containsKey("error"), object.getString("error_description"));
|
||||
|
||||
return AuthUser.builder()
|
||||
.rawUserInfo(object)
|
||||
.uuid(object.getString("id"))
|
||||
.username(object.getString("login"))
|
||||
.avatar(object.getString("avatar_url"))
|
||||
|
||||
@@ -51,6 +51,7 @@ public class AuthGitlabRequest extends AuthDefaultRequest {
|
||||
this.checkResponse(object);
|
||||
|
||||
return AuthUser.builder()
|
||||
.rawUserInfo(object)
|
||||
.uuid(object.getString("id"))
|
||||
.username(object.getString("username"))
|
||||
.nickname(object.getString("name"))
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package me.zhyd.oauth.request;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.xkcoding.http.HttpUtil;
|
||||
import me.zhyd.oauth.utils.HttpUtils;
|
||||
import com.xkcoding.http.support.HttpHeader;
|
||||
import me.zhyd.oauth.cache.AuthStateCache;
|
||||
import me.zhyd.oauth.config.AuthConfig;
|
||||
@@ -47,10 +47,11 @@ public class AuthGoogleRequest extends AuthDefaultRequest {
|
||||
protected AuthUser getUserInfo(AuthToken authToken) {
|
||||
HttpHeader httpHeader = new HttpHeader();
|
||||
httpHeader.add("Authorization", "Bearer " + authToken.getAccessToken());
|
||||
String userInfo = HttpUtil.post(userInfoUrl(authToken), null, httpHeader);
|
||||
String userInfo = new HttpUtils(config.getHttpConfig()).post(userInfoUrl(authToken), null, httpHeader);
|
||||
JSONObject object = JSONObject.parseObject(userInfo);
|
||||
this.checkResponse(object);
|
||||
return AuthUser.builder()
|
||||
.rawUserInfo(object)
|
||||
.uuid(object.getString("sub"))
|
||||
.username(object.getString("email"))
|
||||
.avatar(object.getString("picture"))
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package me.zhyd.oauth.request;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.xkcoding.http.HttpUtil;
|
||||
import me.zhyd.oauth.utils.HttpUtils;
|
||||
import me.zhyd.oauth.cache.AuthStateCache;
|
||||
import me.zhyd.oauth.config.AuthConfig;
|
||||
import me.zhyd.oauth.config.AuthDefaultSource;
|
||||
@@ -52,7 +52,7 @@ public class AuthHuaweiRequest extends AuthDefaultRequest {
|
||||
form.put("client_secret", config.getClientSecret());
|
||||
form.put("redirect_uri", config.getRedirectUri());
|
||||
|
||||
String response = HttpUtil.post(source.accessToken(), form, false);
|
||||
String response = new HttpUtils(config.getHttpConfig()).post(source.accessToken(), form, false);
|
||||
return getAuthToken(response);
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ public class AuthHuaweiRequest extends AuthDefaultRequest {
|
||||
form.put("nsp_fmt", "JS");
|
||||
form.put("nsp_svc", "OpenUP.User.getInfo");
|
||||
|
||||
String response = HttpUtil.post(source.userInfo(), form, false);
|
||||
String response = new HttpUtils(config.getHttpConfig()).post(source.userInfo(), form, false);
|
||||
JSONObject object = JSONObject.parseObject(response);
|
||||
|
||||
this.checkResponse(object);
|
||||
@@ -79,6 +79,7 @@ public class AuthHuaweiRequest extends AuthDefaultRequest {
|
||||
AuthUserGender gender = getRealGender(object);
|
||||
|
||||
return AuthUser.builder()
|
||||
.rawUserInfo(object)
|
||||
.uuid(object.getString("userID"))
|
||||
.username(object.getString("userName"))
|
||||
.nickname(object.getString("userName"))
|
||||
@@ -103,7 +104,7 @@ public class AuthHuaweiRequest extends AuthDefaultRequest {
|
||||
form.put("refresh_token", authToken.getRefreshToken());
|
||||
form.put("grant_type", "refresh_token");
|
||||
|
||||
String response = HttpUtil.post(source.refresh(), form, false);
|
||||
String response = new HttpUtils(config.getHttpConfig()).post(source.refresh(), form, false);
|
||||
return AuthResponse.builder().code(SUCCESS.getCode()).data(getAuthToken(response)).build();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package me.zhyd.oauth.request;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.xkcoding.http.HttpUtil;
|
||||
import me.zhyd.oauth.utils.HttpUtils;
|
||||
import me.zhyd.oauth.cache.AuthStateCache;
|
||||
import me.zhyd.oauth.config.AuthConfig;
|
||||
import me.zhyd.oauth.config.AuthDefaultSource;
|
||||
@@ -44,7 +44,7 @@ public class AuthJdRequest extends AuthDefaultRequest {
|
||||
params.put("app_secret", config.getClientSecret());
|
||||
params.put("grant_type", "authorization_code");
|
||||
params.put("code", authCallback.getCode());
|
||||
String response = HttpUtil.post(source.accessToken(), params, false);
|
||||
String response = new HttpUtils(config.getHttpConfig()).post(source.accessToken(), params, false);
|
||||
JSONObject object = JSONObject.parseObject(response);
|
||||
|
||||
this.checkResponse(object);
|
||||
@@ -68,7 +68,7 @@ public class AuthJdRequest extends AuthDefaultRequest {
|
||||
.queryParam("timestamp", LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")))
|
||||
.queryParam("v", "2.0");
|
||||
urlBuilder.queryParam("sign", GlobalAuthUtils.generateJdSignature(config.getClientSecret(), urlBuilder.getReadOnlyParams()));
|
||||
String response = HttpUtil.post(urlBuilder.build(true));
|
||||
String response = new HttpUtils(config.getHttpConfig()).post(urlBuilder.build(true));
|
||||
JSONObject object = JSONObject.parseObject(response);
|
||||
|
||||
this.checkResponse(object);
|
||||
@@ -76,6 +76,7 @@ public class AuthJdRequest extends AuthDefaultRequest {
|
||||
JSONObject data = this.getUserDataJsonObject(object);
|
||||
|
||||
return AuthUser.builder()
|
||||
.rawUserInfo(data)
|
||||
.uuid(authToken.getOpenId())
|
||||
.username(data.getString("nickName"))
|
||||
.nickname(data.getString("nickName"))
|
||||
@@ -106,7 +107,7 @@ public class AuthJdRequest extends AuthDefaultRequest {
|
||||
params.put("app_secret", config.getClientSecret());
|
||||
params.put("grant_type", "refresh_token");
|
||||
params.put("refresh_token", oldToken.getRefreshToken());
|
||||
String response = HttpUtil.post(source.refresh(), params, false);
|
||||
String response = new HttpUtils(config.getHttpConfig()).post(source.refresh(), params, false);
|
||||
JSONObject object = JSONObject.parseObject(response);
|
||||
|
||||
this.checkResponse(object);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package me.zhyd.oauth.request;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.xkcoding.http.HttpUtil;
|
||||
import me.zhyd.oauth.utils.HttpUtils;
|
||||
import me.zhyd.oauth.cache.AuthStateCache;
|
||||
import me.zhyd.oauth.config.AuthConfig;
|
||||
import me.zhyd.oauth.config.AuthDefaultSource;
|
||||
@@ -90,7 +90,7 @@ public class AuthKujialeRequest extends AuthDefaultRequest {
|
||||
@Override
|
||||
public AuthUser getUserInfo(AuthToken authToken) {
|
||||
String openId = this.getOpenId(authToken);
|
||||
String response = HttpUtil.get(UrlBuilder.fromBaseUrl(source.userInfo())
|
||||
String response = new HttpUtils(config.getHttpConfig()).get(UrlBuilder.fromBaseUrl(source.userInfo())
|
||||
.queryParam("access_token", authToken.getAccessToken())
|
||||
.queryParam("open_id", openId)
|
||||
.build());
|
||||
@@ -101,6 +101,7 @@ public class AuthKujialeRequest extends AuthDefaultRequest {
|
||||
JSONObject resultObject = object.getJSONObject("d");
|
||||
|
||||
return AuthUser.builder()
|
||||
.rawUserInfo(resultObject)
|
||||
.username(resultObject.getString("userName"))
|
||||
.nickname(resultObject.getString("userName"))
|
||||
.avatar(resultObject.getString("avatar"))
|
||||
@@ -117,7 +118,7 @@ public class AuthKujialeRequest extends AuthDefaultRequest {
|
||||
* @return openId
|
||||
*/
|
||||
private String getOpenId(AuthToken authToken) {
|
||||
String response = HttpUtil.get(UrlBuilder.fromBaseUrl("https://oauth.kujiale.com/oauth2/auth/user")
|
||||
String response = new HttpUtils(config.getHttpConfig()).get(UrlBuilder.fromBaseUrl("https://oauth.kujiale.com/oauth2/auth/user")
|
||||
.queryParam("access_token", authToken.getAccessToken())
|
||||
.build());
|
||||
JSONObject accessTokenObject = checkResponse(response);
|
||||
@@ -126,7 +127,7 @@ public class AuthKujialeRequest extends AuthDefaultRequest {
|
||||
|
||||
@Override
|
||||
public AuthResponse refresh(AuthToken authToken) {
|
||||
String response = HttpUtil.post(refreshTokenUrl(authToken.getRefreshToken()));
|
||||
String response = new HttpUtils(config.getHttpConfig()).post(refreshTokenUrl(authToken.getRefreshToken()));
|
||||
return AuthResponse.builder().code(AuthResponseStatus.SUCCESS.getCode()).data(getAuthToken(response)).build();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package me.zhyd.oauth.request;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.JSONPath;
|
||||
import com.xkcoding.http.HttpUtil;
|
||||
import com.xkcoding.http.constants.Constants;
|
||||
import com.xkcoding.http.support.HttpHeader;
|
||||
import me.zhyd.oauth.cache.AuthStateCache;
|
||||
@@ -16,6 +15,7 @@ import me.zhyd.oauth.model.AuthCallback;
|
||||
import me.zhyd.oauth.model.AuthResponse;
|
||||
import me.zhyd.oauth.model.AuthToken;
|
||||
import me.zhyd.oauth.model.AuthUser;
|
||||
import me.zhyd.oauth.utils.HttpUtils;
|
||||
import me.zhyd.oauth.utils.StringUtils;
|
||||
import me.zhyd.oauth.utils.UrlBuilder;
|
||||
|
||||
@@ -49,7 +49,7 @@ public class AuthLinkedinRequest extends AuthDefaultRequest {
|
||||
httpHeader.add("Connection", "Keep-Alive");
|
||||
httpHeader.add("Authorization", "Bearer " + accessToken);
|
||||
|
||||
String response = HttpUtil.get(userInfoUrl(authToken), null, httpHeader, false);
|
||||
String response = new HttpUtils(config.getHttpConfig()).get(userInfoUrl(authToken), null, httpHeader, false);
|
||||
JSONObject userInfoObject = JSONObject.parseObject(response);
|
||||
|
||||
this.checkResponse(userInfoObject);
|
||||
@@ -62,6 +62,7 @@ public class AuthLinkedinRequest extends AuthDefaultRequest {
|
||||
// 获取用户邮箱地址
|
||||
String email = this.getUserEmail(accessToken);
|
||||
return AuthUser.builder()
|
||||
.rawUserInfo(userInfoObject)
|
||||
.uuid(userInfoObject.getString("id"))
|
||||
.username(userName)
|
||||
.nickname(userName)
|
||||
@@ -103,17 +104,27 @@ public class AuthLinkedinRequest extends AuthDefaultRequest {
|
||||
* @return 用户的头像地址
|
||||
*/
|
||||
private String getAvatar(JSONObject userInfoObject) {
|
||||
String avatar = null;
|
||||
JSONObject profilePictureObject = userInfoObject.getJSONObject("profilePicture");
|
||||
if (profilePictureObject.containsKey("displayImage~")) {
|
||||
JSONArray displayImageElements = profilePictureObject.getJSONObject("displayImage~")
|
||||
.getJSONArray("elements");
|
||||
if (null != displayImageElements && displayImageElements.size() > 0) {
|
||||
JSONObject largestImageObj = displayImageElements.getJSONObject(displayImageElements.size() - 1);
|
||||
avatar = largestImageObj.getJSONArray("identifiers").getJSONObject(0).getString("identifier");
|
||||
}
|
||||
if (null == profilePictureObject || !profilePictureObject.containsKey("displayImage~")) {
|
||||
return null;
|
||||
}
|
||||
return avatar;
|
||||
JSONObject displayImageObject = profilePictureObject.getJSONObject("displayImage~");
|
||||
if (null == displayImageObject || !displayImageObject.containsKey("elements")) {
|
||||
return null;
|
||||
}
|
||||
JSONArray displayImageElements = displayImageObject.getJSONArray("elements");
|
||||
if (null == displayImageElements || displayImageElements.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
JSONObject largestImageObj = displayImageElements.getJSONObject(displayImageElements.size() - 1);
|
||||
if (null == largestImageObj || !largestImageObj.containsKey("identifiers")) {
|
||||
return null;
|
||||
}
|
||||
JSONArray identifiers = largestImageObj.getJSONArray("identifiers");
|
||||
if (null == identifiers || identifiers.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return identifiers.getJSONObject(0).getString("identifier");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -128,7 +139,7 @@ public class AuthLinkedinRequest extends AuthDefaultRequest {
|
||||
httpHeader.add("Connection", "Keep-Alive");
|
||||
httpHeader.add("Authorization", "Bearer " + accessToken);
|
||||
|
||||
String emailResponse = HttpUtil.get("https://api.linkedin.com/v2/emailAddress?q=members&projection=(elements*(handle~))", null, httpHeader, false);
|
||||
String emailResponse = new HttpUtils(config.getHttpConfig()).get("https://api.linkedin.com/v2/emailAddress?q=members&projection=(elements*(handle~))", null, httpHeader, false);
|
||||
JSONObject emailObj = JSONObject.parseObject(emailResponse);
|
||||
|
||||
this.checkResponse(emailObj);
|
||||
@@ -181,7 +192,7 @@ public class AuthLinkedinRequest extends AuthDefaultRequest {
|
||||
httpHeader.add("Host", "www.linkedin.com");
|
||||
httpHeader.add(Constants.CONTENT_TYPE, "application/x-www-form-urlencoded");
|
||||
|
||||
String response = HttpUtil.post(accessTokenUrl, null, httpHeader);
|
||||
String response = new HttpUtils(config.getHttpConfig()).post(accessTokenUrl, null, httpHeader);
|
||||
JSONObject accessTokenObject = JSONObject.parseObject(response);
|
||||
|
||||
this.checkResponse(accessTokenObject);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package me.zhyd.oauth.request;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.xkcoding.http.HttpUtil;
|
||||
import me.zhyd.oauth.utils.HttpUtils;
|
||||
import me.zhyd.oauth.cache.AuthStateCache;
|
||||
import me.zhyd.oauth.config.AuthConfig;
|
||||
import me.zhyd.oauth.config.AuthDefaultSource;
|
||||
@@ -41,7 +41,7 @@ public class AuthMeituanRequest extends AuthDefaultRequest {
|
||||
form.put("code", authCallback.getCode());
|
||||
form.put("grant_type", "authorization_code");
|
||||
|
||||
String response = HttpUtil.post(source.accessToken(), form, false);
|
||||
String response = new HttpUtils(config.getHttpConfig()).post(source.accessToken(), form, false);
|
||||
JSONObject object = JSONObject.parseObject(response);
|
||||
|
||||
this.checkResponse(object);
|
||||
@@ -60,12 +60,13 @@ public class AuthMeituanRequest extends AuthDefaultRequest {
|
||||
form.put("secret", config.getClientSecret());
|
||||
form.put("access_token", authToken.getAccessToken());
|
||||
|
||||
String response = HttpUtil.post(source.userInfo(), form, false);
|
||||
String response = new HttpUtils(config.getHttpConfig()).post(source.userInfo(), form, false);
|
||||
JSONObject object = JSONObject.parseObject(response);
|
||||
|
||||
this.checkResponse(object);
|
||||
|
||||
return AuthUser.builder()
|
||||
.rawUserInfo(object)
|
||||
.uuid(object.getString("openid"))
|
||||
.username(object.getString("nickname"))
|
||||
.nickname(object.getString("nickname"))
|
||||
@@ -84,7 +85,7 @@ public class AuthMeituanRequest extends AuthDefaultRequest {
|
||||
form.put("refresh_token", oldToken.getRefreshToken());
|
||||
form.put("grant_type", "refresh_token");
|
||||
|
||||
String response = HttpUtil.post(source.refresh(), form, false);
|
||||
String response = new HttpUtils(config.getHttpConfig()).post(source.refresh(), form, false);
|
||||
JSONObject object = JSONObject.parseObject(response);
|
||||
|
||||
this.checkResponse(object);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package me.zhyd.oauth.request;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.xkcoding.http.HttpUtil;
|
||||
import me.zhyd.oauth.utils.HttpUtils;
|
||||
import com.xkcoding.http.constants.Constants;
|
||||
import me.zhyd.oauth.cache.AuthStateCache;
|
||||
import me.zhyd.oauth.config.AuthConfig;
|
||||
@@ -41,7 +41,7 @@ public class AuthMiRequest extends AuthDefaultRequest {
|
||||
}
|
||||
|
||||
private AuthToken getToken(String accessTokenUrl) {
|
||||
String response = HttpUtil.get(accessTokenUrl);
|
||||
String response = new HttpUtils(config.getHttpConfig()).get(accessTokenUrl);
|
||||
String jsonStr = response.replace(PREFIX, Constants.EMPTY);
|
||||
JSONObject accessTokenObject = JSONObject.parseObject(jsonStr);
|
||||
|
||||
@@ -71,14 +71,15 @@ public class AuthMiRequest extends AuthDefaultRequest {
|
||||
throw new AuthException(userProfile.getString("description"));
|
||||
}
|
||||
|
||||
JSONObject user = userProfile.getJSONObject("data");
|
||||
JSONObject object = userProfile.getJSONObject("data");
|
||||
|
||||
AuthUser authUser = AuthUser.builder()
|
||||
.rawUserInfo(object)
|
||||
.uuid(authToken.getOpenId())
|
||||
.username(user.getString("miliaoNick"))
|
||||
.nickname(user.getString("miliaoNick"))
|
||||
.avatar(user.getString("miliaoIcon"))
|
||||
.email(user.getString("mail"))
|
||||
.username(object.getString("miliaoNick"))
|
||||
.nickname(object.getString("miliaoNick"))
|
||||
.avatar(object.getString("miliaoIcon"))
|
||||
.email(object.getString("mail"))
|
||||
.gender(AuthUserGender.UNKNOWN)
|
||||
.token(authToken)
|
||||
.source(source.toString())
|
||||
@@ -88,7 +89,7 @@ public class AuthMiRequest extends AuthDefaultRequest {
|
||||
String emailPhoneUrl = MessageFormat.format("{0}?clientId={1}&token={2}", "https://open.account.xiaomi.com/user/phoneAndEmail", config
|
||||
.getClientId(), authToken.getAccessToken());
|
||||
|
||||
String emailResponse = HttpUtil.get(emailPhoneUrl);
|
||||
String emailResponse = new HttpUtils(config.getHttpConfig()).get(emailPhoneUrl);
|
||||
JSONObject userEmailPhone = JSONObject.parseObject(emailResponse);
|
||||
if (!"error".equalsIgnoreCase(userEmailPhone.getString("result"))) {
|
||||
JSONObject emailPhone = userEmailPhone.getJSONObject("data");
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package me.zhyd.oauth.request;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.xkcoding.http.HttpUtil;
|
||||
import me.zhyd.oauth.utils.HttpUtils;
|
||||
import com.xkcoding.http.constants.Constants;
|
||||
import com.xkcoding.http.support.HttpHeader;
|
||||
import com.xkcoding.http.util.MapUtil;
|
||||
@@ -47,12 +47,10 @@ public class AuthMicrosoftRequest extends AuthDefaultRequest {
|
||||
*/
|
||||
private AuthToken getToken(String accessTokenUrl) {
|
||||
HttpHeader httpHeader = new HttpHeader();
|
||||
httpHeader.add("Host", "https://login.microsoftonline.com");
|
||||
httpHeader.add(Constants.CONTENT_TYPE, "application/x-www-form-urlencoded");
|
||||
|
||||
Map<String, String> form = MapUtil.parseStringToMap(accessTokenUrl, false);
|
||||
|
||||
String response = HttpUtil.post(accessTokenUrl, form, httpHeader, false);
|
||||
String response = new HttpUtils(config.getHttpConfig()).post(accessTokenUrl, form, httpHeader, false);
|
||||
JSONObject accessTokenObject = JSONObject.parseObject(response);
|
||||
|
||||
this.checkResponse(accessTokenObject);
|
||||
@@ -86,10 +84,11 @@ public class AuthMicrosoftRequest extends AuthDefaultRequest {
|
||||
HttpHeader httpHeader = new HttpHeader();
|
||||
httpHeader.add("Authorization", jwt);
|
||||
|
||||
String userInfo = HttpUtil.get(userInfoUrl(authToken), null, httpHeader, false);
|
||||
String userInfo = new HttpUtils(config.getHttpConfig()).get(userInfoUrl(authToken), null, httpHeader, false);
|
||||
JSONObject object = JSONObject.parseObject(userInfo);
|
||||
this.checkResponse(object);
|
||||
return AuthUser.builder()
|
||||
.rawUserInfo(object)
|
||||
.uuid(object.getString("id"))
|
||||
.username(object.getString("userPrincipalName"))
|
||||
.nickname(object.getString("displayName"))
|
||||
@@ -129,7 +128,7 @@ public class AuthMicrosoftRequest extends AuthDefaultRequest {
|
||||
.queryParam("client_id", config.getClientId())
|
||||
.queryParam("redirect_uri", config.getRedirectUri())
|
||||
.queryParam("response_mode", "query")
|
||||
.queryParam("scope", "offline_access%20user.read%20mail.read")
|
||||
.queryParam("scope", "offline_access user.read mail.read")
|
||||
.queryParam("state", getRealState(state))
|
||||
.build();
|
||||
}
|
||||
@@ -147,7 +146,7 @@ public class AuthMicrosoftRequest extends AuthDefaultRequest {
|
||||
.queryParam("client_id", config.getClientId())
|
||||
.queryParam("client_secret", config.getClientSecret())
|
||||
.queryParam("grant_type", "authorization_code")
|
||||
.queryParam("scope", "user.read%20mail.read")
|
||||
.queryParam("scope", "offline_access user.read mail.read")
|
||||
.queryParam("redirect_uri", config.getRedirectUri())
|
||||
.build();
|
||||
}
|
||||
|
||||
@@ -46,6 +46,7 @@ public class AuthOschinaRequest extends AuthDefaultRequest {
|
||||
JSONObject object = JSONObject.parseObject(response);
|
||||
this.checkResponse(object);
|
||||
return AuthUser.builder()
|
||||
.rawUserInfo(object)
|
||||
.uuid(object.getString("id"))
|
||||
.username(object.getString("name"))
|
||||
.nickname(object.getString("name"))
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package me.zhyd.oauth.request;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.xkcoding.http.HttpUtil;
|
||||
import me.zhyd.oauth.utils.HttpUtils;
|
||||
import me.zhyd.oauth.cache.AuthStateCache;
|
||||
import me.zhyd.oauth.config.AuthConfig;
|
||||
import me.zhyd.oauth.enums.AuthUserGender;
|
||||
@@ -48,11 +48,12 @@ public class AuthPinterestRequest extends AuthDefaultRequest {
|
||||
protected AuthUser getUserInfo(AuthToken authToken) {
|
||||
String userinfoUrl = userInfoUrl(authToken);
|
||||
// TODO: 是否需要 .setFollowRedirects(true)
|
||||
String response = HttpUtil.get(userinfoUrl);
|
||||
String response = new HttpUtils(config.getHttpConfig()).get(userinfoUrl);
|
||||
JSONObject object = JSONObject.parseObject(response);
|
||||
this.checkResponse(object);
|
||||
JSONObject userObj = object.getJSONObject("data");
|
||||
return AuthUser.builder()
|
||||
.rawUserInfo(userObj)
|
||||
.uuid(userObj.getString("id"))
|
||||
.avatar(getAvatarUrl(userObj))
|
||||
.username(userObj.getString("username"))
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package me.zhyd.oauth.request;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.xkcoding.http.HttpUtil;
|
||||
import me.zhyd.oauth.utils.HttpUtils;
|
||||
import me.zhyd.oauth.cache.AuthStateCache;
|
||||
import me.zhyd.oauth.config.AuthConfig;
|
||||
import me.zhyd.oauth.config.AuthDefaultSource;
|
||||
@@ -42,7 +42,7 @@ public class AuthQqRequest extends AuthDefaultRequest {
|
||||
|
||||
@Override
|
||||
public AuthResponse refresh(AuthToken authToken) {
|
||||
String response = HttpUtil.get(refreshTokenUrl(authToken.getRefreshToken()));
|
||||
String response = new HttpUtils(config.getHttpConfig()).get(refreshTokenUrl(authToken.getRefreshToken()));
|
||||
return AuthResponse.builder().code(AuthResponseStatus.SUCCESS.getCode()).data(getAuthToken(response)).build();
|
||||
}
|
||||
|
||||
@@ -61,6 +61,7 @@ public class AuthQqRequest extends AuthDefaultRequest {
|
||||
|
||||
String location = String.format("%s-%s", object.getString("province"), object.getString("city"));
|
||||
return AuthUser.builder()
|
||||
.rawUserInfo(object)
|
||||
.username(object.getString("nickname"))
|
||||
.nickname(object.getString("nickname"))
|
||||
.avatar(avatar)
|
||||
@@ -80,7 +81,7 @@ public class AuthQqRequest extends AuthDefaultRequest {
|
||||
* @return openId
|
||||
*/
|
||||
private String getOpenId(AuthToken authToken) {
|
||||
String response = HttpUtil.get(UrlBuilder.fromBaseUrl("https://graph.qq.com/oauth2.0/me")
|
||||
String response = new HttpUtils(config.getHttpConfig()).get(UrlBuilder.fromBaseUrl("https://graph.qq.com/oauth2.0/me")
|
||||
.queryParam("access_token", authToken.getAccessToken())
|
||||
.queryParam("unionid", config.isUnionId() ? 1 : 0)
|
||||
.build());
|
||||
|
||||
@@ -2,7 +2,7 @@ package me.zhyd.oauth.request;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.xkcoding.http.HttpUtil;
|
||||
import com.xkcoding.http.util.UrlUtil;
|
||||
import me.zhyd.oauth.cache.AuthStateCache;
|
||||
import me.zhyd.oauth.config.AuthConfig;
|
||||
import me.zhyd.oauth.enums.AuthUserGender;
|
||||
@@ -11,6 +11,7 @@ import me.zhyd.oauth.model.AuthCallback;
|
||||
import me.zhyd.oauth.model.AuthResponse;
|
||||
import me.zhyd.oauth.model.AuthToken;
|
||||
import me.zhyd.oauth.model.AuthUser;
|
||||
import me.zhyd.oauth.utils.HttpUtils;
|
||||
import me.zhyd.oauth.utils.UrlBuilder;
|
||||
|
||||
import java.util.Objects;
|
||||
@@ -45,6 +46,7 @@ public class AuthRenrenRequest extends AuthDefaultRequest {
|
||||
JSONObject userObj = JSONObject.parseObject(response).getJSONObject("response");
|
||||
|
||||
return AuthUser.builder()
|
||||
.rawUserInfo(userObj)
|
||||
.uuid(userObj.getString("id"))
|
||||
.avatar(getAvatarUrl(userObj))
|
||||
.nickname(userObj.getString("name"))
|
||||
@@ -64,7 +66,7 @@ public class AuthRenrenRequest extends AuthDefaultRequest {
|
||||
}
|
||||
|
||||
private AuthToken getToken(String url) {
|
||||
String response = HttpUtil.post(url);
|
||||
String response = new HttpUtils(config.getHttpConfig()).post(url);
|
||||
JSONObject jsonObject = JSONObject.parseObject(response);
|
||||
if (jsonObject.containsKey("error")) {
|
||||
throw new AuthException("Failed to get token from Renren: " + jsonObject);
|
||||
@@ -73,8 +75,8 @@ public class AuthRenrenRequest extends AuthDefaultRequest {
|
||||
return AuthToken.builder()
|
||||
.tokenType(jsonObject.getString("token_type"))
|
||||
.expireIn(jsonObject.getIntValue("expires_in"))
|
||||
.accessToken(jsonObject.getString("access_token"))
|
||||
.refreshToken(jsonObject.getString("refresh_token"))
|
||||
.accessToken(UrlUtil.urlEncode(jsonObject.getString("access_token")))
|
||||
.refreshToken(UrlUtil.urlEncode(jsonObject.getString("refresh_token")))
|
||||
.openId(jsonObject.getJSONObject("user").getString("id"))
|
||||
.build();
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package me.zhyd.oauth.request;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.xkcoding.http.HttpUtil;
|
||||
import me.zhyd.oauth.utils.HttpUtils;
|
||||
import com.xkcoding.http.constants.Constants;
|
||||
import com.xkcoding.http.support.HttpHeader;
|
||||
import com.xkcoding.http.util.MapUtil;
|
||||
@@ -40,7 +40,7 @@ public class AuthStackOverflowRequest extends AuthDefaultRequest {
|
||||
Map<String, String> form = MapUtil.parseStringToMap(accessTokenUrl, false);
|
||||
HttpHeader httpHeader = new HttpHeader();
|
||||
httpHeader.add(Constants.CONTENT_TYPE, "application/x-www-form-urlencoded");
|
||||
String response = HttpUtil.post(accessTokenUrl, form, httpHeader, false);
|
||||
String response = new HttpUtils(config.getHttpConfig()).post(accessTokenUrl, form, httpHeader, false);
|
||||
|
||||
JSONObject accessTokenObject = JSONObject.parseObject(response);
|
||||
this.checkResponse(accessTokenObject);
|
||||
@@ -58,12 +58,13 @@ public class AuthStackOverflowRequest extends AuthDefaultRequest {
|
||||
.queryParam("site", "stackoverflow")
|
||||
.queryParam("key", this.config.getStackOverflowKey())
|
||||
.build();
|
||||
String response = HttpUtil.get(userInfoUrl);
|
||||
String response = new HttpUtils(config.getHttpConfig()).get(userInfoUrl);
|
||||
JSONObject object = JSONObject.parseObject(response);
|
||||
this.checkResponse(object);
|
||||
JSONObject userObj = object.getJSONArray("items").getJSONObject(0);
|
||||
|
||||
return AuthUser.builder()
|
||||
.rawUserInfo(userObj)
|
||||
.uuid(userObj.getString("user_id"))
|
||||
.avatar(userObj.getString("profile_image"))
|
||||
.location(userObj.getString("location"))
|
||||
|
||||
@@ -48,6 +48,7 @@ public class AuthTaobaoRequest extends AuthDefaultRequest {
|
||||
|
||||
String nick = GlobalAuthUtils.urlDecode(accessTokenObject.getString("taobao_user_nick"));
|
||||
return AuthUser.builder()
|
||||
.rawUserInfo(new JSONObject())
|
||||
.uuid(accessTokenObject.getString("taobao_user_id"))
|
||||
.username(nick)
|
||||
.nickname(nick)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package me.zhyd.oauth.request;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.xkcoding.http.HttpUtil;
|
||||
import me.zhyd.oauth.utils.HttpUtils;
|
||||
import com.xkcoding.http.support.HttpHeader;
|
||||
import me.zhyd.oauth.cache.AuthStateCache;
|
||||
import me.zhyd.oauth.config.AuthConfig;
|
||||
@@ -45,7 +45,7 @@ public class AuthTeambitionRequest extends AuthDefaultRequest {
|
||||
form.put("code", authCallback.getCode());
|
||||
form.put("grant_type", "code");
|
||||
|
||||
String response = HttpUtil.post(source.accessToken(), form, false);
|
||||
String response = new HttpUtils(config.getHttpConfig()).post(source.accessToken(), form, false);
|
||||
JSONObject accessTokenObject = JSONObject.parseObject(response);
|
||||
|
||||
this.checkResponse(accessTokenObject);
|
||||
@@ -63,7 +63,7 @@ public class AuthTeambitionRequest extends AuthDefaultRequest {
|
||||
HttpHeader httpHeader = new HttpHeader();
|
||||
httpHeader.add("Authorization", "OAuth2 " + accessToken);
|
||||
|
||||
String response = HttpUtil.get(source.userInfo(), null, httpHeader, false);
|
||||
String response = new HttpUtils(config.getHttpConfig()).get(source.userInfo(), null, httpHeader, false);
|
||||
JSONObject object = JSONObject.parseObject(response);
|
||||
|
||||
this.checkResponse(object);
|
||||
@@ -71,6 +71,7 @@ public class AuthTeambitionRequest extends AuthDefaultRequest {
|
||||
authToken.setUid(object.getString("_id"));
|
||||
|
||||
return AuthUser.builder()
|
||||
.rawUserInfo(object)
|
||||
.uuid(object.getString("_id"))
|
||||
.username(object.getString("name"))
|
||||
.nickname(object.getString("name"))
|
||||
@@ -92,7 +93,7 @@ public class AuthTeambitionRequest extends AuthDefaultRequest {
|
||||
Map<String, String> form = new HashMap<>(2);
|
||||
form.put("_userId", uid);
|
||||
form.put("refresh_token", refreshToken);
|
||||
String response = HttpUtil.post(source.refresh(), form, false);
|
||||
String response = new HttpUtils(config.getHttpConfig()).post(source.refresh(), form, false);
|
||||
JSONObject refreshTokenObject = JSONObject.parseObject(response);
|
||||
|
||||
this.checkResponse(refreshTokenObject);
|
||||
|
||||
@@ -1,93 +0,0 @@
|
||||
package me.zhyd.oauth.request;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import me.zhyd.oauth.cache.AuthStateCache;
|
||||
import me.zhyd.oauth.config.AuthConfig;
|
||||
import me.zhyd.oauth.config.AuthDefaultSource;
|
||||
import me.zhyd.oauth.enums.AuthUserGender;
|
||||
import me.zhyd.oauth.exception.AuthException;
|
||||
import me.zhyd.oauth.model.AuthCallback;
|
||||
import me.zhyd.oauth.model.AuthToken;
|
||||
import me.zhyd.oauth.model.AuthUser;
|
||||
import me.zhyd.oauth.utils.UrlBuilder;
|
||||
|
||||
/**
|
||||
* 腾讯云登录
|
||||
*
|
||||
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class AuthTencentCloudRequest extends AuthDefaultRequest {
|
||||
|
||||
public AuthTencentCloudRequest(AuthConfig config) {
|
||||
super(config, AuthDefaultSource.TENCENT_CLOUD);
|
||||
}
|
||||
|
||||
public AuthTencentCloudRequest(AuthConfig config, AuthStateCache authStateCache) {
|
||||
super(config, AuthDefaultSource.TENCENT_CLOUD, authStateCache);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AuthToken getAccessToken(AuthCallback authCallback) {
|
||||
String response = doGetAuthorizationCode(authCallback.getCode());
|
||||
JSONObject accessTokenObject = JSONObject.parseObject(response);
|
||||
this.checkResponse(accessTokenObject);
|
||||
return AuthToken.builder()
|
||||
.accessToken(accessTokenObject.getString("access_token"))
|
||||
.expireIn(accessTokenObject.getIntValue("expires_in"))
|
||||
.refreshToken(accessTokenObject.getString("refresh_token"))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AuthUser getUserInfo(AuthToken authToken) {
|
||||
String response = doGetUserInfo(authToken);
|
||||
JSONObject object = JSONObject.parseObject(response);
|
||||
this.checkResponse(object);
|
||||
|
||||
object = object.getJSONObject("data");
|
||||
return AuthUser.builder()
|
||||
.uuid(object.getString("id"))
|
||||
.username(object.getString("name"))
|
||||
.avatar("https://dev.tencent.com/" + object.getString("avatar"))
|
||||
.blog("https://dev.tencent.com/" + object.getString("path"))
|
||||
.nickname(object.getString("name"))
|
||||
.company(object.getString("company"))
|
||||
.location(object.getString("location"))
|
||||
.gender(AuthUserGender.getRealGender(object.getString("sex")))
|
||||
.email(object.getString("email"))
|
||||
.remark(object.getString("slogan"))
|
||||
.token(authToken)
|
||||
.source(source.toString())
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查响应内容是否正确
|
||||
*
|
||||
* @param object 请求响应内容
|
||||
*/
|
||||
private void checkResponse(JSONObject object) {
|
||||
if (object.getIntValue("code") != 0) {
|
||||
throw new AuthException(object.getString("msg"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回带{@code state}参数的授权url,授权回调时会带上这个{@code state}
|
||||
*
|
||||
* @param state state 验证授权流程的参数,可以防止csrf
|
||||
* @return 返回授权地址
|
||||
* @since 1.9.3
|
||||
*/
|
||||
@Override
|
||||
public String authorize(String state) {
|
||||
return UrlBuilder.fromBaseUrl(source.authorize())
|
||||
.queryParam("response_type", "code")
|
||||
.queryParam("client_id", config.getClientId())
|
||||
.queryParam("redirect_uri", config.getRedirectUri())
|
||||
.queryParam("scope", "user")
|
||||
.queryParam("state", getRealState(state))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -56,6 +56,7 @@ public class AuthToutiaoRequest extends AuthDefaultRequest {
|
||||
String anonymousUserName = "匿名用户";
|
||||
|
||||
return AuthUser.builder()
|
||||
.rawUserInfo(user)
|
||||
.uuid(user.getString("uid"))
|
||||
.username(isAnonymousUser ? anonymousUserName : user.getString("screen_name"))
|
||||
.nickname(isAnonymousUser ? anonymousUserName : user.getString("screen_name"))
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package me.zhyd.oauth.request;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.xkcoding.http.HttpUtil;
|
||||
import me.zhyd.oauth.utils.HttpUtils;
|
||||
import com.xkcoding.http.constants.Constants;
|
||||
import com.xkcoding.http.support.HttpHeader;
|
||||
import com.xkcoding.http.util.MapUtil;
|
||||
@@ -38,6 +38,21 @@ public class AuthTwitterRequest extends AuthDefaultRequest {
|
||||
super(config, TWITTER, authStateCache);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回带{@code state}参数的授权url,授权回调时会带上这个{@code state}
|
||||
*
|
||||
* @param state state 验证授权流程的参数,可以防止csrf
|
||||
* @return 返回授权地址
|
||||
* @since 1.9.3
|
||||
*/
|
||||
@Override
|
||||
public String authorize(String state) {
|
||||
AuthToken token = this.getRequestToken();
|
||||
return UrlBuilder.fromBaseUrl(source.authorize())
|
||||
.queryParam("oauth_token", token.getOauthToken())
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtaining a request token
|
||||
* https://developer.twitter.com/en/docs/twitter-for-websites/log-in-with-twitter/guides/implementing-sign-in-with-twitter
|
||||
@@ -54,7 +69,10 @@ public class AuthTwitterRequest extends AuthDefaultRequest {
|
||||
|
||||
HttpHeader httpHeader = new HttpHeader();
|
||||
httpHeader.add("Authorization", header);
|
||||
String requestToken = HttpUtil.post(baseUrl, null, httpHeader);
|
||||
httpHeader.add("User-Agent", "themattharris' HTTP Client");
|
||||
httpHeader.add("Host", "api.twitter.com");
|
||||
httpHeader.add("Accept", "*/*");
|
||||
String requestToken = new HttpUtils(config.getHttpConfig()).post(baseUrl, null, httpHeader);
|
||||
|
||||
Map<String, String> res = MapUtil.parseStringToMap(requestToken, false);
|
||||
|
||||
@@ -74,10 +92,10 @@ public class AuthTwitterRequest extends AuthDefaultRequest {
|
||||
@Override
|
||||
protected AuthToken getAccessToken(AuthCallback authCallback) {
|
||||
Map<String, String> oauthParams = buildOauthParams();
|
||||
oauthParams.put("oauth_token", authCallback.getOauthToken());
|
||||
oauthParams.put("oauth_verifier", authCallback.getOauthVerifier());
|
||||
oauthParams.put("oauth_token", authCallback.getOauth_token());
|
||||
oauthParams.put("oauth_verifier", authCallback.getOauth_verifier());
|
||||
oauthParams.put("oauth_signature", generateTwitterSignature(oauthParams, "POST", source.accessToken(), config.getClientSecret(), authCallback
|
||||
.getOauthToken()));
|
||||
.getOauth_token()));
|
||||
String header = buildHeader(oauthParams);
|
||||
|
||||
HttpHeader httpHeader = new HttpHeader();
|
||||
@@ -85,8 +103,8 @@ public class AuthTwitterRequest extends AuthDefaultRequest {
|
||||
httpHeader.add(Constants.CONTENT_TYPE, "application/x-www-form-urlencoded");
|
||||
|
||||
Map<String, String> form = new HashMap<>(1);
|
||||
form.put("oauth_verifier", authCallback.getOauthVerifier());
|
||||
String response = HttpUtil.post(source.accessToken(), form, httpHeader, false);
|
||||
form.put("oauth_verifier", authCallback.getOauth_verifier());
|
||||
String response = new HttpUtils(config.getHttpConfig()).post(source.accessToken(), form, httpHeader, false);
|
||||
|
||||
Map<String, String> requestToken = MapUtil.parseStringToMap(response, false);
|
||||
|
||||
@@ -116,10 +134,11 @@ public class AuthTwitterRequest extends AuthDefaultRequest {
|
||||
|
||||
HttpHeader httpHeader = new HttpHeader();
|
||||
httpHeader.add("Authorization", header);
|
||||
String response = HttpUtil.get(userInfoUrl(authToken), null, httpHeader, false);
|
||||
String response = new HttpUtils(config.getHttpConfig()).get(userInfoUrl(authToken), null, httpHeader, false);
|
||||
JSONObject userInfo = JSONObject.parseObject(response);
|
||||
|
||||
return AuthUser.builder()
|
||||
.rawUserInfo(userInfo)
|
||||
.uuid(userInfo.getString("id_str"))
|
||||
.username(userInfo.getString("screen_name"))
|
||||
.nickname(userInfo.getString("name"))
|
||||
@@ -127,6 +146,7 @@ public class AuthTwitterRequest extends AuthDefaultRequest {
|
||||
.avatar(userInfo.getString("profile_image_url_https"))
|
||||
.blog(userInfo.getString("url"))
|
||||
.location(userInfo.getString("location"))
|
||||
.avatar(userInfo.getString("profile_image_url"))
|
||||
.source(source.toString())
|
||||
.token(authToken)
|
||||
.build();
|
||||
@@ -152,15 +172,12 @@ public class AuthTwitterRequest extends AuthDefaultRequest {
|
||||
}
|
||||
|
||||
private String buildHeader(Map<String, String> oauthParams) {
|
||||
final StringBuilder sb = new StringBuilder(PREAMBLE);
|
||||
final StringBuilder sb = new StringBuilder(PREAMBLE + " ");
|
||||
|
||||
for (Map.Entry<String, String> param : oauthParams.entrySet()) {
|
||||
if (sb.length() > PREAMBLE.length()) {
|
||||
sb.append(", ");
|
||||
}
|
||||
sb.append(param.getKey()).append("=\"").append(urlEncode(param.getValue())).append('"');
|
||||
sb.append(param.getKey()).append("=\"").append(urlEncode(param.getValue())).append('"').append(", ");
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
return sb.deleteCharAt(sb.length() - 2).toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package me.zhyd.oauth.request;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.xkcoding.http.HttpUtil;
|
||||
import me.zhyd.oauth.utils.HttpUtils;
|
||||
import me.zhyd.oauth.cache.AuthStateCache;
|
||||
import me.zhyd.oauth.config.AuthConfig;
|
||||
import me.zhyd.oauth.config.AuthDefaultSource;
|
||||
@@ -63,6 +63,7 @@ public class AuthWeChatEnterpriseRequest extends AuthDefaultRequest {
|
||||
JSONObject userDetail = this.checkResponse(userDetailResponse);
|
||||
|
||||
return AuthUser.builder()
|
||||
.rawUserInfo(userDetail)
|
||||
.username(userDetail.getString("name"))
|
||||
.nickname(userDetail.getString("alias"))
|
||||
.avatar(userDetail.getString("avatar"))
|
||||
@@ -148,7 +149,7 @@ public class AuthWeChatEnterpriseRequest extends AuthDefaultRequest {
|
||||
.queryParam("access_token", accessToken)
|
||||
.queryParam("userid", userId)
|
||||
.build();
|
||||
return HttpUtil.get(userDetailUrl);
|
||||
return new HttpUtils(config.getHttpConfig()).get(userDetailUrl);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package me.zhyd.oauth.request;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.xkcoding.http.HttpUtil;
|
||||
import me.zhyd.oauth.utils.HttpUtils;
|
||||
import me.zhyd.oauth.cache.AuthStateCache;
|
||||
import me.zhyd.oauth.config.AuthConfig;
|
||||
import me.zhyd.oauth.config.AuthDefaultSource;
|
||||
@@ -57,6 +57,7 @@ public class AuthWeChatMpRequest extends AuthDefaultRequest {
|
||||
}
|
||||
|
||||
return AuthUser.builder()
|
||||
.rawUserInfo(object)
|
||||
.username(object.getString("nickname"))
|
||||
.nickname(object.getString("nickname"))
|
||||
.avatar(object.getString("headimgurl"))
|
||||
@@ -94,7 +95,7 @@ public class AuthWeChatMpRequest extends AuthDefaultRequest {
|
||||
* @return token对象
|
||||
*/
|
||||
private AuthToken getToken(String accessTokenUrl) {
|
||||
String response = HttpUtil.get(accessTokenUrl);
|
||||
String response = new HttpUtils(config.getHttpConfig()).get(accessTokenUrl);
|
||||
JSONObject accessTokenObject = JSONObject.parseObject(response);
|
||||
|
||||
this.checkResponse(accessTokenObject);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package me.zhyd.oauth.request;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.xkcoding.http.HttpUtil;
|
||||
import me.zhyd.oauth.utils.HttpUtils;
|
||||
import me.zhyd.oauth.cache.AuthStateCache;
|
||||
import me.zhyd.oauth.config.AuthConfig;
|
||||
import me.zhyd.oauth.config.AuthDefaultSource;
|
||||
@@ -56,6 +56,7 @@ public class AuthWeChatOpenRequest extends AuthDefaultRequest {
|
||||
}
|
||||
|
||||
return AuthUser.builder()
|
||||
.rawUserInfo(object)
|
||||
.username(object.getString("nickname"))
|
||||
.nickname(object.getString("nickname"))
|
||||
.avatar(object.getString("headimgurl"))
|
||||
@@ -93,7 +94,7 @@ public class AuthWeChatOpenRequest extends AuthDefaultRequest {
|
||||
* @return token对象
|
||||
*/
|
||||
private AuthToken getToken(String accessTokenUrl) {
|
||||
String response = HttpUtil.get(accessTokenUrl);
|
||||
String response = new HttpUtils(config.getHttpConfig()).get(accessTokenUrl);
|
||||
JSONObject accessTokenObject = JSONObject.parseObject(response);
|
||||
|
||||
this.checkResponse(accessTokenObject);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package me.zhyd.oauth.request;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.xkcoding.http.HttpUtil;
|
||||
import me.zhyd.oauth.utils.HttpUtils;
|
||||
import com.xkcoding.http.support.HttpHeader;
|
||||
import me.zhyd.oauth.cache.AuthStateCache;
|
||||
import me.zhyd.oauth.config.AuthConfig;
|
||||
@@ -58,12 +58,13 @@ public class AuthWeiboRequest extends AuthDefaultRequest {
|
||||
HttpHeader httpHeader = new HttpHeader();
|
||||
httpHeader.add("Authorization", "OAuth2 " + oauthParam);
|
||||
httpHeader.add("API-RemoteIP", IpUtils.getLocalIp());
|
||||
String userInfo = HttpUtil.get(userInfoUrl(authToken), null, httpHeader, false);
|
||||
String userInfo = new HttpUtils(config.getHttpConfig()).get(userInfoUrl(authToken), null, httpHeader, false);
|
||||
JSONObject object = JSONObject.parseObject(userInfo);
|
||||
if (object.containsKey("error")) {
|
||||
throw new AuthException(object.getString("error"));
|
||||
}
|
||||
return AuthUser.builder()
|
||||
.rawUserInfo(object)
|
||||
.uuid(object.getString("id"))
|
||||
.username(object.getString("name"))
|
||||
.avatar(object.getString("profile_image_url"))
|
||||
|
||||
@@ -35,6 +35,9 @@ public class AuthChecker {
|
||||
if (isSupported && AuthDefaultSource.WECHAT_ENTERPRISE == source) {
|
||||
isSupported = StringUtils.isNotEmpty(config.getAgentId());
|
||||
}
|
||||
if (isSupported && AuthDefaultSource.CODING == source) {
|
||||
isSupported = StringUtils.isNotEmpty(config.getCodingGroupName());
|
||||
}
|
||||
return isSupported;
|
||||
}
|
||||
|
||||
@@ -72,6 +75,10 @@ public class AuthChecker {
|
||||
* @since 1.8.0
|
||||
*/
|
||||
public static void checkCode(AuthSource source, AuthCallback callback) {
|
||||
// 推特平台不支持回调 code 和 state
|
||||
if (source == AuthDefaultSource.TWITTER) {
|
||||
return;
|
||||
}
|
||||
String code = callback.getCode();
|
||||
if (source == AuthDefaultSource.ALIPAY) {
|
||||
code = callback.getAuth_code();
|
||||
@@ -95,6 +102,10 @@ public class AuthChecker {
|
||||
* @param authStateCache {@code authStateCache} state缓存实现
|
||||
*/
|
||||
public static void checkState(String state, AuthSource source, AuthStateCache authStateCache) {
|
||||
// 推特平台不支持回调 code 和 state
|
||||
if (source == AuthDefaultSource.TWITTER) {
|
||||
return;
|
||||
}
|
||||
if (StringUtils.isEmpty(state) || !authStateCache.containsKey(state)) {
|
||||
throw new AuthException(AuthResponseStatus.ILLEGAL_STATUS, source);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
package me.zhyd.oauth.utils;
|
||||
|
||||
import com.xkcoding.http.HttpUtil;
|
||||
import com.xkcoding.http.config.HttpConfig;
|
||||
import com.xkcoding.http.support.HttpHeader;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* HttpUtil 工具,统一处理 http 请求,方便对 simple-http 做定制
|
||||
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
|
||||
* @version 1.0.0
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class HttpUtils {
|
||||
|
||||
public HttpUtils(HttpConfig config) {
|
||||
HttpUtil.setConfig(config);
|
||||
}
|
||||
|
||||
public HttpUtils() {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* GET 请求
|
||||
*
|
||||
* @param url URL
|
||||
* @return 结果
|
||||
*/
|
||||
public String get(String url) {
|
||||
return HttpUtil.get(url);
|
||||
}
|
||||
|
||||
/**
|
||||
* GET 请求
|
||||
*
|
||||
* @param url URL
|
||||
* @param params 参数
|
||||
* @param header 请求头
|
||||
* @param encode 是否需要 url encode
|
||||
* @return 结果
|
||||
*/
|
||||
public String get(String url, Map<String, String> params, HttpHeader header, boolean encode) {
|
||||
return HttpUtil.get(url, params, header, encode);
|
||||
}
|
||||
|
||||
/**
|
||||
* POST 请求
|
||||
*
|
||||
* @param url URL
|
||||
* @return 结果
|
||||
*/
|
||||
public String post(String url) {
|
||||
return HttpUtil.post(url);
|
||||
}
|
||||
|
||||
/**
|
||||
* POST 请求
|
||||
*
|
||||
* @param url URL
|
||||
* @param data JSON 参数
|
||||
* @return 结果
|
||||
*/
|
||||
public String post(String url, String data) {
|
||||
return HttpUtil.post(url, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* POST 请求
|
||||
*
|
||||
* @param url URL
|
||||
* @param data JSON 参数
|
||||
* @param header 请求头
|
||||
* @return 结果
|
||||
*/
|
||||
public String post(String url, String data, HttpHeader header) {
|
||||
return HttpUtil.post(url, data, header);
|
||||
}
|
||||
|
||||
/**
|
||||
* POST 请求
|
||||
*
|
||||
* @param url URL
|
||||
* @param params form 参数
|
||||
* @param encode 是否需要 url encode
|
||||
* @return 结果
|
||||
*/
|
||||
public String post(String url, Map<String, String> params, boolean encode) {
|
||||
return HttpUtil.post(url, params, encode);
|
||||
}
|
||||
|
||||
/**
|
||||
* POST 请求
|
||||
*
|
||||
* @param url URL
|
||||
* @param params form 参数
|
||||
* @param header 请求头
|
||||
* @param encode 是否需要 url encode
|
||||
* @return 结果
|
||||
*/
|
||||
public String post(String url, Map<String, String> params, HttpHeader header, boolean encode) {
|
||||
return HttpUtil.post(url, params, header, encode);
|
||||
}
|
||||
}
|
||||
@@ -92,20 +92,20 @@ public class GlobalAuthUtilsTest {
|
||||
.clientSecret("0YX3RH2DnPiT77pgzLzFdfpMKX8ENLIWQKYQ7lG5TERuZNgXN5")
|
||||
.build();
|
||||
AuthCallback authCallback = AuthCallback.builder()
|
||||
.oauthToken("W_KLmAAAAAAAxq5LAAABbXxJeD0")
|
||||
.oauthVerifier("lYou4gxfA6S5KioUa8VF8HCShzA2nSxp")
|
||||
.oauth_token("W_KLmAAAAAAAxq5LAAABbXxJeD0")
|
||||
.oauth_verifier("lYou4gxfA6S5KioUa8VF8HCShzA2nSxp")
|
||||
.build();
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("oauth_consumer_key", config.getClientId());
|
||||
params.put("oauth_nonce", "sTj7Ivg73u052eXstpoS1AWQCynuDEPN");
|
||||
params.put("oauth_signature_method", "HMAC-SHA1");
|
||||
params.put("oauth_timestamp", "1569751082");
|
||||
params.put("oauth_token", authCallback.getOauthToken());
|
||||
params.put("oauth_verifier", authCallback.getOauthVerifier());
|
||||
params.put("oauth_token", authCallback.getOauth_token());
|
||||
params.put("oauth_verifier", authCallback.getOauth_verifier());
|
||||
params.put("oauth_version", "1.0");
|
||||
|
||||
params.put("oauth_signature", GlobalAuthUtils.generateTwitterSignature(params, "POST", TWITTER.accessToken(), config.getClientSecret(), authCallback
|
||||
.getOauthToken()));
|
||||
.getOauth_token()));
|
||||
|
||||
params.forEach((k, v) -> params.put(k, "\"" + GlobalAuthUtils.urlEncode(v) + "\""));
|
||||
String actual = "OAuth " + GlobalAuthUtils.parseMapToString(params, false).replaceAll("&", ", ");
|
||||
|
||||