從申請 Google OAuth2.0 憑證到應用 - OAuth介紹與應用
OAuth 介紹 [1]
- 授權標準協議
- 讓第三方應用程式可以存取使用者的資源
- 根據不同grant types分為四個流程 - authorization code, implicit, resource owner password credentials, and client credentials.
角色
- Client (Your application)
- Resource owner (End user)
- Resource server (like Google)
- Authorization server (like Google)
基本流程圖
以下為基本架構,實際會根據不同的grant types分為四種流程
四種流程差異
在 (C) 步驟有所差別
- authorization code: 遵循基本流程圖 (最安全)
- implicit: 在 Authorization server 提供的 login page 登入成功後,核發 access token
- resource owner password credentials: 以使用者帳號/密碼換取 access token
- client credentials: 以 clientID, clientSecret 換取 access token
應用 (以Google為例)
前提:要有架好的server去接收grant code (Google 使用的為 Authorization code flow)
以下會以flow + postman搭配來說明
1. 由使用者透過應用程式選擇Google登入,發送request到google server
發送參數為之前介紹提到之下載的憑證資訊