Update oauth2.md

This commit is contained in:
xxq250 2025-10-15 14:58:21 +08:00
parent 8b39d43460
commit 96231da6fe
1 changed files with 4 additions and 4 deletions

View File

@ -20,13 +20,13 @@ OAuth2 认证基本流程
`https://gitlink.org.cn/oauth/authorize?client_id={client_id}&redirect_uri={redirect_uri}&response_type=code&scope=user_info`
* 红山认证服务器通过回调地址`{redirect_uri}`将 用户授权码 传递给 应用服务器 或者直接在 Webview 中跳转到携带 用户授权码的回调地址上Webview 直接获取code即可`{redirect_uri}?code=abc&state=xyz`)
* 应用服务器 或 Webview 使用 access_token API 向 红山认证服务器发送post请求传入 用户授权码 以及 回调地址( POST请求
* 平台认证服务器通过回调地址`{redirect_uri}`将 用户授权码 传递给 应用服务器 或者直接在 Webview 中跳转到携带 用户授权码的回调地址上Webview 直接获取code即可`{redirect_uri}?code=abc&state=xyz`)
* 应用服务器 或 Webview 使用 access_token API 向平台认证服务器发送post请求传入 用户授权码 以及 回调地址( POST请求
注:请求过程建议将 client_secret 放在 Body 中传值,以保证数据安全。
`https://gitlink.org.cn/oauth/token?grant_type=authorization_code&code={code}&client_id={client_id}&redirect_uri={redirect_uri}&client_secret={client_secret}`
* 红山认证服务器返回 access_token
* 平台认证服务器返回 access_token
应用通过 access_token 访问 Open API 使用用户数据。
当 access_token 过期后(有效期为一天),你可以通过以下 refresh_token 方式重新获取 access_token POST请求
@ -37,7 +37,7 @@ OAuth2 认证基本流程
详见获取Token时服务端响应状态403是什么情况
### 2. 密码模式
* 用户向客户端提供邮箱地址和密码。客户端将邮箱地址和密码发给红山认证服务器,并向红山认证服务器请求令牌。( POST请求。Content-Type: application/x-www-form-urlencoded
* 用户向客户端提供邮箱地址和密码。客户端将邮箱地址和密码发给平台认证服务器,并向平台认证服务器请求令牌。( POST请求。Content-Type: application/x-www-form-urlencoded
`curl -X POST --data-urlencode "grant_type=password" --data-urlencode "username={email}" --data-urlencode "password={password}" --data-urlencode "client_id={client_id}" --data-urlencode "client_secret={client_secret}" --data-urlencode "scope=user_info" https://gitlink.org.cn/oauth/token`