Upgrade to Pro — share decks privately, control downloads, hide ads and more …

OAuth 2.0 Authorization Code Flow

OAuth 2.0 Authorization Code Flow

demos for OAuth 2.0 Authorization Code Flow

Ching Yi Chan

February 15, 2020
Tweet

More Decks by Ching Yi Chan

Other Decks in How-to & DIY

Transcript

  1. OAuth 2.0 Authorization Code Flow

  2. Authentication

  3. Email login Password

  4. Email login Password username email password WHERE email = ?

    AND password = ?
  5. Email login Password username email password WHERE email = ?

    AND password = ? hi {username} login failed
  6. Delegated Authorization with OAuth 2.0

  7. https://blog.yorkxin.org/2013/09/30/oauth2-4-1-auth-code-grant-flow.html

  8. login with google Email Password twjug-lite.com accounts.google.com login

  9. login with google Email Password twjug-lite.com accounts.google.com login No Yes

    你同意 TWJUG lite 使 用 OOO XXX 嗎? accounts.google.com
  10. login with google Email Password twjug-lite.com accounts.google.com login No Yes

    accounts.google.com twjug-lite.com/callback loading ... xxx.google.com 你同意 TWJUG lite 使 用 OOO XXX 嗎?
  11. login with google Email Password twjug-lite.com accounts.google.com login Yes accounts.google.com

    twjug-lite.com/callback loading ... xxx.google.com Client Authorization Sserver Resource Server User-Agent, a.k.a. 瀏覽器 Consent Resource Owner 你同意 TWJUG lite 使 用 OOO XXX 嗎?
  12. RE: 重零開始的 OAuth Flow 細節⽣活

  13. login with google Email Password twjug-lite.com accounts.google.com login No Yes

    accounts.google.com 1 response_type: code redirect_uri: twjut-lite.com/callback go to authorization server 你同意 TWJUG lite 使 用 OOO XXX 嗎?
  14. login with google Email Password twjug-lite.com accounts.google.com login No Yes

    accounts.google.com twjug-lite.com/callback loading ... 1 2 response_type: code redirect_uri: twjut-lite.com/callback go to authorization server Back to redirect URI with authorization code 你同意 TWJUG lite 使 用 OOO XXX 嗎?
  15. login with google Email Password twjug-lite.com accounts.google.com login No Yes

    accounts.google.com twjug-lite.com/callback loading ... 1 2 3 response_type: code redirect_uri: twjut-lite.com/callback go to authorization server Back to redirect URI with authorization code Exchange authorization code for access token 你同意 TWJUG lite 使 用 OOO XXX 嗎?
  16. login with google Email Password twjug-lite.com accounts.google.com login No Yes

    accounts.google.com twjug-lite.com/callback loading ... 1 2 xxx.google.com 3 4 response_type: code redirect_uri: twjut-lite.com/callback go to authorization server Back to redirect URI with authorization code Exchange authorization code for access token Talk to resource server with access token 你同意 TWJUG lite 使 用 OOO XXX 嗎?
  17. 動⼿做看看 https://auth0.com/docs/api-auth/tutorials/authorization-code-grant

  18. login with google Email Password twjug-lite.com accounts.google.com login 1 client_id:

    xxxx response_type: code redirect_uri: twjut-lite.com/callback go to authorization server 0 向 OAuth Provider 註冊你的 Client 取得 client_id, client_secret
  19. Email Password accounts.google.com login No Yes accounts.google.com twjug-lite.com/callback loading ...

    2 Back to redirect URI with authorization code Exchange authorization code for access token 你同意 TWJUG lite 使 用 OOO XXX 嗎? 3