OAuth2
四种授权模式
1. Authorization Code(授权码模式)
- 授权请求
参数 | 是否必填 | 限制条件 |
---|---|---|
response_type | 是 | code |
client_id | 是 | |
redirect_uri | 可选 | |
scope | 可选 | |
state | 推荐 |
- 令牌请求
参数 | 是否必填 | 限制条件 |
---|---|---|
grant_type | 是 | authorization_code |
code | 是 | |
redirect_uri | 是 | 必须与生成 code 时的 redirect_uri 一样 |
client_id | 是 | |
client_secret | 是 |
2. Implicit(简单模式)
- 授权请求
参数 | 是否必填 | 限制条件 |
---|---|---|
response_type | 是 | token |
client_id | 是 | |
redirect_uri | 可选 | |
scope | 可选 | |
state | 推荐 |
3. Resource Owner Password Credentials(密码模式)
- 令牌请求
参数 | 是否必填 | 限制条件 |
---|---|---|
grant_type | 是 | password |
username | 是 | |
password | 是 | 必须与生成 code 时的 redirect_uri 一样 |
scope | 可选 |
4. Client Credentials(客户端模式)
- 令牌请求
参数 | 是否必填 | 限制条件 |
---|---|---|
grant_type | 是 | client_credentials |
scope | 可选 |