uauth
update:
- 添加 password 模式示例
run
go run . svc
go run . client
浏览器打开
http://localhost:18080/login
oauth2 authorization flow(password mode)
-
- 客户端直接拿到用户的账号和密码来请求 oauth2 服务器获取 token
oauth2 authorization flow(authorization_code mode)
-
- 某某 系统/平台(比如: xx_platform) 的用户想要登录该 系统/平台, 并点击到登录页面
-
-
用户发现该平台上有
通过 {oauth2} 登录
的按钮, 用户点击该按钮, 跳转到{oauth2}
服务的登录页面如:/oauth2/login
example: https://oauth2.com/login?client_id=...&scope=...&redirect_uri=...
需要注意, 这些参数都是必须的
-
-
- 跳转过来后, 有两种情况: 1. 用户没有在 {oauth2} 服务上登录过, 且当前的 token 依旧有效, 2. 用户在 {oauth2} 服务上未登录或者 token 已经过期
- 3.1 如果用户登录过且 token 有效, 则跳转到
/oauth2/authorize
进行授权 - 3.2 如果用户没有登录过, 或 token 已经失效, 则在登录成功后, 则跳转到
/oauth2/authorize
进行授权
-
- 授权后, 会跳转到 redirect_uri 参数指定的地址, 并带上 code 和 state 参数
-
- xx_platform 拿到 code 参数后, 向 {oauth2} 服务通过 code 请求 access_token
Description
Languages
Go
79.9%
HTML
20.1%