1. 授权模式的访问

1)浏览器中访问Oauth2.0
[http://localhost:2003/auth-server/oauth/authorize?response_type=code&client_id=myjszl&redirect_uri=http://www.baidu.com](http://localhost:2003/auth-server/oauth/authorize?response_type=code&client_id=myjszl&redirect_uri=http://www.baidu.com)

如果没登录,会重定向到登录页面
image.png
待请求成功后,跳转到重定向的uri并在后面添加了code: [https://www.baidu.com/?code=0AawwM](https://www.baidu.com/?code=0AawwM)

2) 根据code,获取access_token

  1. http://localhost:8080/oauth/token?
  2. grant_type=authorization_code
  3. &code=o4YrCS&client_id=pair
  4. &client_secret=secret&redirect_uri=http://baidu.com
  1. http://localhost:8080/oauth/token?
  2. grant_type=refresh_token
  3. &refresh_token=ce3dd10e-ec60-4399-9076-ee2140b04a61
  4. &client_id=pair&client_secret=secret

3) 根据access_token获取资源
[http://localhost:8080/rest/api/ping?access_token=a8ae6a78-289d-4594-a421-9b56aa8f7213](http://localhost:8080/rest/api/ping?access_token=a8ae6a78-289d-4594-a421-9b56aa8f7213)

参考文档:

  1. https://blog.csdn.net/u013887008/article/details/80616422