代码拉取完成,页面将自动刷新
Oauth2支持的授权方式目前有5类
GRANT_TYPE | Description |
---|---|
authorization_code | 授权码模式(即先登录获取code,再获取token) [最常用] |
password | 密码模式(将用户名、密码传过去,直接获取token) [适用于移动设备] |
client_credentials | 客户端模式(无用户,用户向客户端注册,然后客户端以自己的名义向'服务端'获取资源) |
implicit | 简化模式(在redirect_uri的Hash传递token,客户端运行在浏览器中,如JS、Flash) |
refresh_token | 更新access_token |
http://localhost:8080/oauth/authorize?response_type=code&scope=read write&client_id=curl-client&redirect_uri=http://www.baidu.com&state=b375bc2b-25f7-4dce-9b36-5f9e2d20bda1
http://www.baidu.com/?code=kG4F2N&state=b375bc2b-25f7-4dce-9b36-5f9e2d20bda1
curl -X POST http://localhost:8080/oauth/token -H "Content-Type: application/x-www-form-urlencoded" -d "client_id=curl-client&client_secret=client-secret&grant_type=authorization_code&code=kG4F2N&redirect_uri=http://www.baidu.com"
{"access_token":"30626e87-761f-410c-9497-84b29d310dd7","token_type":"bearer","refresh_token":"0843fbec-20e3-4802-93a0-357488403924","expires_in":29,"scope":"read write"}
curl http://localhost:8080/user/ping -H "Authorization: Bearer 30626e87-761f-410c-9497-84b29d310dd7"
curl -X POST http://localhost:8080/oauth/token -H "Content-Type: application/x-www-form-urlencoded" -d "grant_type=password&scope=read%20write&client_id=curl-client&client_secret=client-secret&username=nangzi&password=nangzi"
{"access_token":"9ac3fe0f-f380-4149-8fca-19a72374365d","token_type":"bearer","refresh_token":"0843fbec-20e3-4802-93a0-357488403924","expires_in":29,"scope":"read write"}
curl http://localhost:8080/user/ping -H "Authorization: Bearer 9ac3fe0f-f380-4149-8fca-19a72374365d"
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。