How OAuth 2.0 sign-in works

An animated explainer of the OAuth 2.0 authorization code flow with PKCE: the redirect, consent, the code exchange, access and refresh tokens.

Chapters

  1. Click & redirect: You click Sign in with Google. The app keeps a random secret, then sends your browser to Google with its client_id, scopes and a hashed fingerprint called the PKCE challenge.
  2. Sign in & approve: You sign in to Google, never to the app, then approve what it may see. Say no, and Google simply sends you back to the app with an error.
  3. Code for tokens: Google redirects back with a short-lived, single-use code. The app server trades code plus secret for tokens; Google hashes the secret and checks it matches the fingerprint.
  4. Call the API & refresh: The app shows the access token on every API call, like a wristband. After about an hour it expires, and the refresh token quietly gets a new one.

Make an animated explainer of your own topic →

More explainers

← All explainers

Try AI Flowchart free →