mirror of
https://gitee.com/yadong.zhang/JustAuth.git
synced 2026-01-07 19:31:48 +08:00
📝 更新文档
This commit is contained in:
parent
ddde4ef1f5
commit
6ea1d41211
@ -52,10 +52,14 @@ scope 对应获取的用户信息关系表如下:
|
||||
|
||||
注:密钥创建完成后记得要保存,因为密钥只能在创建完成后明文显示一次,如丢失或者忘记,请重新创建。
|
||||
|
||||
|
||||
**重要提示:“应用密钥”可保护你应用程序的安全,因此请确保其不会泄露!也不要与任何人共享你的“应用密钥”!!!**
|
||||
|
||||
|
||||
## 3. 集成JustAuth
|
||||
|
||||
|
||||
### 2.1 引入依赖
|
||||
### 3.1 引入依赖
|
||||
|
||||
```xml
|
||||
<dependency>
|
||||
@ -67,7 +71,7 @@ scope 对应获取的用户信息关系表如下:
|
||||
|
||||
`${latest.version}`表示当前最新的版本,可以在[这儿](https://github.com/justauth/JustAuth/releases)获取最新的版本信息。
|
||||
|
||||
### 2.2 创建Request
|
||||
### 3.2 创建Request
|
||||
|
||||
```java
|
||||
AuthRequest authRequest = new AuthAliyunRequest(AuthConfig.builder()
|
||||
@ -78,7 +82,7 @@ AuthRequest authRequest = new AuthAliyunRequest(AuthConfig.builder()
|
||||
.build());
|
||||
```
|
||||
|
||||
### 2.3 生成授权地址
|
||||
### 3.3 生成授权地址
|
||||
|
||||
我们可以直接使用以下方式生成第三方平台的授权链接:
|
||||
```java
|
||||
@ -87,7 +91,7 @@ String authorizeUrl = authRequest.authorize(AuthStateUtils.createState());
|
||||
这个链接我们可以直接后台重定向跳转,也可以返回到前端后,前端控制跳转。前端控制的好处就是,可以将第三方的授权页嵌入到iframe中,适配网站设计。
|
||||
|
||||
|
||||
### 2.4 以上完整代码如下
|
||||
### 3.4 以上完整代码如下
|
||||
|
||||
```java
|
||||
import me.zhyd.oauth.config.AuthConfig;
|
||||
@ -129,7 +133,7 @@ public class RestAuthController {
|
||||
}
|
||||
```
|
||||
|
||||
## 3. 授权结果
|
||||
## 4. 授权结果
|
||||
|
||||
```json
|
||||
{
|
||||
@ -178,4 +182,22 @@ public class RestAuthController {
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
```
|
||||
|
||||
## 5. 推荐
|
||||
|
||||
官方推荐使用 [JustAuth-demo](https://github.com/justauth/JustAuth-demo) 示例项目进行测试。
|
||||
|
||||
使用步骤:
|
||||
1. clone: [https://github.com/justauth/JustAuth-demo.git](https://github.com/justauth/JustAuth-demo.git)
|
||||
2. 将上面申请的应用信息填入到`RestAuthController#getAuthRequest`方法的对应位置中:
|
||||

|
||||
3. 启动项目,访问 [http://localhost:8443](http://localhost:8443)
|
||||
4. 选择对应的平台进行授权登录
|
||||

|
||||
5. 登录完成后,可以访问[http://localhost:8443/users](http://localhost:8443/users)查看已授权的用户
|
||||

|
||||
|
||||
注:
|
||||
1. 如果直接使用 JustAuth-demo 项目进行测试,那么在配置测试应用的“回调地址”时要严格按照以下格式配置:`http://localhost:8443/oauth/callback/{平台名}`
|
||||
2. 平台名参考 `JustAuthPlatformInfo` 枚举类 `names`
|
||||
|
||||
@ -20,6 +20,9 @@
|
||||

|
||||
|
||||
|
||||
**重要提示:“应用密钥”可保护你应用程序的安全,因此请确保其不会泄露!也不要与任何人共享你的“应用密钥”!!!**
|
||||
|
||||
|
||||
## 2. 集成JustAuth
|
||||
|
||||
### 2.1 引入依赖
|
||||
|
||||
@ -21,6 +21,10 @@
|
||||
|
||||

|
||||
|
||||
|
||||
**重要提示:“应用密钥”可保护你应用程序的安全,因此请确保其不会泄露!也不要与任何人共享你的“应用密钥”!!!**
|
||||
|
||||
|
||||
## 2. 集成JustAuth
|
||||
|
||||
### 2.1 引入依赖
|
||||
@ -148,4 +152,23 @@ public class RestAuthController {
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
## 4. 推荐
|
||||
|
||||
官方推荐使用 [JustAuth-demo](https://github.com/justauth/JustAuth-demo) 示例项目进行测试。
|
||||
|
||||
使用步骤:
|
||||
1. clone: [https://github.com/justauth/JustAuth-demo.git](https://github.com/justauth/JustAuth-demo.git)
|
||||
2. 将上面申请的应用信息填入到`RestAuthController#getAuthRequest`方法的对应位置中:
|
||||

|
||||
3. 启动项目,访问 [http://localhost:8443](http://localhost:8443)
|
||||
4. 选择对应的平台进行授权登录
|
||||

|
||||
5. 登录完成后,可以访问[http://localhost:8443/users](http://localhost:8443/users)查看已授权的用户
|
||||

|
||||
|
||||
注:
|
||||
1. 如果直接使用 JustAuth-demo 项目进行测试,那么在配置测试应用的“回调地址”时要严格按照以下格式配置:`http://localhost:8443/oauth/callback/{平台名}`
|
||||
2. 平台名参考 `JustAuthPlatformInfo` 枚举类 `names`
|
||||
|
||||
@ -24,6 +24,7 @@
|
||||
|
||||
记录以下三个信息:`appId`、`appSecret`和`回调域名`,后面我们会用到。
|
||||
|
||||
**重要提示:“应用密钥”可保护你应用程序的安全,因此请确保其不会泄露!也不要与任何人共享你的“应用密钥”!!!**
|
||||
|
||||
## 2. 集成JustAuth
|
||||
|
||||
|
||||
@ -26,6 +26,7 @@
|
||||
|
||||
记录以下三个信息:`Client ID`、`Client Secret`和`应用回调地址`,后面我们会用到
|
||||
|
||||
**重要提示:“应用密钥”可保护你应用程序的安全,因此请确保其不会泄露!也不要与任何人共享你的“应用密钥”!!!**
|
||||
|
||||
## 2. 集成JustAuth
|
||||
|
||||
@ -144,3 +145,23 @@ public class RestAuthController {
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## 4. 推荐
|
||||
|
||||
官方推荐使用 [JustAuth-demo](https://github.com/justauth/JustAuth-demo) 示例项目进行测试。
|
||||
|
||||
使用步骤:
|
||||
1. clone: [https://github.com/justauth/JustAuth-demo.git](https://github.com/justauth/JustAuth-demo.git)
|
||||
2. 将上面申请的应用信息填入到`RestAuthController#getAuthRequest`方法的对应位置中:
|
||||

|
||||
3. 启动项目,访问 [http://localhost:8443](http://localhost:8443)
|
||||
4. 选择对应的平台进行授权登录
|
||||

|
||||
5. 登录完成后,可以访问[http://localhost:8443/users](http://localhost:8443/users)查看已授权的用户
|
||||

|
||||
|
||||
注:
|
||||
1. 如果直接使用 JustAuth-demo 项目进行测试,那么在配置测试应用的“回调地址”时要严格按照以下格式配置:`http://localhost:8443/oauth/callback/{平台名}`
|
||||
2. 平台名参考 `JustAuthPlatformInfo` 枚举类 `names`
|
||||
|
||||
|
||||
@ -23,6 +23,8 @@ https://github.com/。如果已有则忽略该步骤,直接进入第二步。
|
||||
|
||||
copy以下三个信息:`Client ID`、`Client Secret`和`Authorization callback URL`。
|
||||
|
||||
**重要提示:“应用密钥”可保护你应用程序的安全,因此请确保其不会泄露!也不要与任何人共享你的“应用密钥”!!!**
|
||||
|
||||
## 2. 集成JustAuth
|
||||
|
||||
|
||||
@ -142,4 +144,23 @@ public class RestAuthController {
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
## 4. 推荐
|
||||
|
||||
官方推荐使用 [JustAuth-demo](https://github.com/justauth/JustAuth-demo) 示例项目进行测试。
|
||||
|
||||
使用步骤:
|
||||
1. clone: [https://github.com/justauth/JustAuth-demo.git](https://github.com/justauth/JustAuth-demo.git)
|
||||
2. 将上面申请的应用信息填入到`RestAuthController#getAuthRequest`方法的对应位置中:
|
||||

|
||||
3. 启动项目,访问 [http://localhost:8443](http://localhost:8443)
|
||||
4. 选择对应的平台进行授权登录
|
||||

|
||||
5. 登录完成后,可以访问[http://localhost:8443/users](http://localhost:8443/users)查看已授权的用户
|
||||

|
||||
|
||||
注:
|
||||
1. 如果直接使用 JustAuth-demo 项目进行测试,那么在配置测试应用的“回调地址”时要严格按照以下格式配置:`http://localhost:8443/oauth/callback/{平台名}`
|
||||
2. 平台名参考 `JustAuthPlatformInfo` 枚举类 `names`
|
||||
|
||||
@ -36,6 +36,8 @@ oauth2.0基础信息
|
||||
|
||||
保存并提交审核后,由运营在管理后台审核应用的相关信息以及应用申请相关权限的合理性。在审核通过后,可以在应用服务模块中查看到该应用,同时访问应用详情可以获取到此应用的秘钥信息(client_id:应用的唯一标识。client_secret:client_id对应的密钥,访问用户资源时用来验证应用的合法性。)
|
||||
|
||||
**重要提示:“应用密钥”可保护你应用程序的安全,因此请确保其不会泄露!也不要与任何人共享你的“应用密钥”!!!**
|
||||
|
||||
## 2. 集成JustAuth
|
||||
|
||||
### 2.1 引入依赖
|
||||
@ -159,4 +161,23 @@ public class RestAuthController {
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
## 4. 推荐
|
||||
|
||||
官方推荐使用 [JustAuth-demo](https://github.com/justauth/JustAuth-demo) 示例项目进行测试。
|
||||
|
||||
使用步骤:
|
||||
1. clone: [https://github.com/justauth/JustAuth-demo.git](https://github.com/justauth/JustAuth-demo.git)
|
||||
2. 将上面申请的应用信息填入到`RestAuthController#getAuthRequest`方法的对应位置中:
|
||||

|
||||
3. 启动项目,访问 [http://localhost:8443](http://localhost:8443)
|
||||
4. 选择对应的平台进行授权登录
|
||||

|
||||
5. 登录完成后,可以访问[http://localhost:8443/users](http://localhost:8443/users)查看已授权的用户
|
||||

|
||||
|
||||
注:
|
||||
1. 如果直接使用 JustAuth-demo 项目进行测试,那么在配置测试应用的“回调地址”时要严格按照以下格式配置:`http://localhost:8443/oauth/callback/{平台名}`
|
||||
2. 平台名参考 `JustAuthPlatformInfo` 枚举类 `names`
|
||||
|
||||
@ -16,6 +16,8 @@ https://connect.qq.com/
|
||||
|
||||
copy以下三个信息:`App ID`、`App Key`和`网站回调域`。
|
||||
|
||||
**重要提示:“应用密钥”可保护你应用程序的安全,因此请确保其不会泄露!也不要与任何人共享你的“应用密钥”!!!**
|
||||
|
||||
## 2. 集成JustAuth
|
||||
|
||||
|
||||
@ -92,6 +94,21 @@ public class RestAuthController {
|
||||
}
|
||||
```
|
||||
|
||||
## 3. 授权结果
|
||||
|
||||
暂无
|
||||
## 3. 推荐
|
||||
|
||||
官方推荐使用 [JustAuth-demo](https://github.com/justauth/JustAuth-demo) 示例项目进行测试。
|
||||
|
||||
使用步骤:
|
||||
1. clone: [https://github.com/justauth/JustAuth-demo.git](https://github.com/justauth/JustAuth-demo.git)
|
||||
2. 将上面申请的应用信息填入到`RestAuthController#getAuthRequest`方法的对应位置中:
|
||||

|
||||
3. 启动项目,访问 [http://localhost:8443](http://localhost:8443)
|
||||
4. 选择对应的平台进行授权登录
|
||||

|
||||
5. 登录完成后,可以访问[http://localhost:8443/users](http://localhost:8443/users)查看已授权的用户
|
||||

|
||||
|
||||
注:
|
||||
1. 如果直接使用 JustAuth-demo 项目进行测试,那么在配置测试应用的“回调地址”时要严格按照以下格式配置:`http://localhost:8443/oauth/callback/{平台名}`
|
||||
2. 平台名参考 `JustAuthPlatformInfo` 枚举类 `names`
|
||||
|
||||
@ -6,6 +6,8 @@ copy以下三个信息:`App ID`、`App Key`和`网站回调域`。
|
||||
|
||||
> 友情提示:twitter现不支持个人用户创建应用
|
||||
|
||||
**重要提示:“应用密钥”可保护你应用程序的安全,因此请确保其不会泄露!也不要与任何人共享你的“应用密钥”!!!**
|
||||
|
||||
## 2. 集成JustAuth
|
||||
|
||||
|
||||
@ -99,6 +101,20 @@ public class RestAuthController {
|
||||
}
|
||||
```
|
||||
|
||||
## 3. 授权结果
|
||||
## 3. 推荐
|
||||
|
||||
暂无
|
||||
官方推荐使用 [JustAuth-demo](https://github.com/justauth/JustAuth-demo) 示例项目进行测试。
|
||||
|
||||
使用步骤:
|
||||
1. clone: [https://github.com/justauth/JustAuth-demo.git](https://github.com/justauth/JustAuth-demo.git)
|
||||
2. 将上面申请的应用信息填入到`RestAuthController#getAuthRequest`方法的对应位置中:
|
||||

|
||||
3. 启动项目,访问 [http://localhost:8443](http://localhost:8443)
|
||||
4. 选择对应的平台进行授权登录
|
||||

|
||||
5. 登录完成后,可以访问[http://localhost:8443/users](http://localhost:8443/users)查看已授权的用户
|
||||

|
||||
|
||||
注:
|
||||
1. 如果直接使用 JustAuth-demo 项目进行测试,那么在配置测试应用的“回调地址”时要严格按照以下格式配置:`http://localhost:8443/oauth/callback/{平台名}`
|
||||
2. 平台名参考 `JustAuthPlatformInfo` 枚举类 `names`
|
||||
|
||||
@ -40,6 +40,8 @@
|
||||
- “授权回调域”填写对应域名即可。比如我想给我的博客 [https://www.zhyd.me](https://www.zhyd.me) 增加微信第三方登录,那么我在配回调地址时,就只需要填写 `www.zhyd.me`即可,实际我们自己开发程序时, 可以随便配置具体的回调地址,只要确保是在 `www.zhyd.me` 下的地址就行。本例中, 我在程序中配置的回调地址为:`https://www.zhyd.me/oauth/callback/wechat`
|
||||
- 重要的事情说三遍:**一定要确保应用详情页的“接口信息”中的“微信登录”接口的状态为“已获得”!** **一定要确保应用详情页的“接口信息”中的“微信登录”接口的状态为“已获得”!** **一定要确保应用详情页的“接口信息”中的“微信登录”接口的状态为“已获得”!**否则一定会遇到这个问题:[“Scope参数错误或者Scope没有权限”是怎么回事?](../Q&A.md?id=_7scope参数错误或者scope没有权限是怎么回事?)
|
||||
|
||||
**重要提示:“应用密钥”可保护你应用程序的安全,因此请确保其不会泄露!也不要与任何人共享你的“应用密钥”!!!**
|
||||
|
||||
|
||||
## 2. 集成JustAuth
|
||||
|
||||
@ -165,4 +167,23 @@ public class RestAuthController {
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
## 4. 推荐
|
||||
|
||||
官方推荐使用 [JustAuth-demo](https://github.com/justauth/JustAuth-demo) 示例项目进行测试。
|
||||
|
||||
使用步骤:
|
||||
1. clone: [https://github.com/justauth/JustAuth-demo.git](https://github.com/justauth/JustAuth-demo.git)
|
||||
2. 将上面申请的应用信息填入到`RestAuthController#getAuthRequest`方法的对应位置中:
|
||||

|
||||
3. 启动项目,访问 [http://localhost:8443](http://localhost:8443)
|
||||
4. 选择对应的平台进行授权登录
|
||||

|
||||
5. 登录完成后,可以访问[http://localhost:8443/users](http://localhost:8443/users)查看已授权的用户
|
||||

|
||||
|
||||
注:
|
||||
1. 如果直接使用 JustAuth-demo 项目进行测试,那么在配置测试应用的“回调地址”时要严格按照以下格式配置:`http://localhost:8443/oauth/callback/{平台名}`
|
||||
2. 平台名参考 `JustAuthPlatformInfo` 枚举类 `names`
|
||||
|
||||
@ -25,6 +25,8 @@ https://open.weibo.com/apps。如果已有则忽略该步骤,直接进入第
|
||||
|
||||
微博平台的OAuth支持revoke操作,所以会有一个【取消授权回调页】配置。
|
||||
|
||||
**重要提示:“应用密钥”可保护你应用程序的安全,因此请确保其不会泄露!也不要与任何人共享你的“应用密钥”!!!**
|
||||
|
||||
## 2. 集成JustAuth
|
||||
|
||||
|
||||
@ -152,4 +154,22 @@ public class RestAuthController {
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
```
|
||||
|
||||
## 4. 推荐
|
||||
|
||||
官方推荐使用 [JustAuth-demo](https://github.com/justauth/JustAuth-demo) 示例项目进行测试。
|
||||
|
||||
使用步骤:
|
||||
1. clone: [https://github.com/justauth/JustAuth-demo.git](https://github.com/justauth/JustAuth-demo.git)
|
||||
2. 将上面申请的应用信息填入到`RestAuthController#getAuthRequest`方法的对应位置中:
|
||||

|
||||
3. 启动项目,访问 [http://localhost:8443](http://localhost:8443)
|
||||
4. 选择对应的平台进行授权登录
|
||||

|
||||
5. 登录完成后,可以访问[http://localhost:8443/users](http://localhost:8443/users)查看已授权的用户
|
||||

|
||||
|
||||
注:
|
||||
1. 如果直接使用 JustAuth-demo 项目进行测试,那么在配置测试应用的“回调地址”时要严格按照以下格式配置:`http://localhost:8443/oauth/callback/{平台名}`
|
||||
2. 平台名参考 `JustAuthPlatformInfo` 枚举类 `names`
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user