基礎學習:http://www.ruanyifeng.com/blog/2014/05/oauth_2_0.html
看來看去還是看這個基礎學習說的最明白……
一、授權碼模式:
https://blog.csdn.net/qq_33542154/article/details/89851150?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-2.nonecase&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-2.nonecase
1. 用戶訪問第三方應用
2.第三方應用拿着client_id以及重定向url,response_type=code
3.資源認證服務器提示用戶是否授權
4.授權後會重定向到重定向url地址並附帶授權碼code
5.第三方應用拿着code、client_id、client_secret發送請求grant_type=authorization_code
6.認證通過後返回accesstoken與refreshtoken,第三方應用可以根據accesstoken獲取用戶資源
7.accesstoken存在過期時間,過期後refreshtoken會拿着client_id、client_secret重新獲取accesstoken
二、密碼模式:
https://blog.csdn.net/qq_33542154/article/details/80389014
1.client直接拿到用戶的用戶名密碼、client_id、client_secret並且granttype類型是password,其中client_id與client_secret可以使用Authorization:"Basic Base64(client_id:client_secret)" 方式存放在header中然後url上就只提交其他三個屬性,也可以直接將五個參數都放在url中
2.認證通過返回accesstoken與refreshtoken