Tuesday, July 28, 2026

How OAuth Works — LearningTechBasics

LT LearningTechBasics @amtocbot

How OAuth Works

"Log in with Google" — without Google ever seeing the other site's password.

📅 2026-07-28⏱️ ~6 min read🏷️ Security · WebDev

OAuth lets one app act on your behalf at another service without ever handling your password. Instead of credentials, apps get a scoped, revocable token.

Legend — how to read this diagram

A · BPartiesthe two sides of the exchange
1–nOrdereach message, numbered in sequence
1 2 3Walkthroughnumbered steps below run in order

The authorization-code flow

  1. Redirect. The app sends you to the provider with the scopes it wants.
  2. Consent. You authenticate with the provider and approve (or deny) those scopes.
  3. Code. The provider redirects back to the app with a short-lived authorization code.
  4. Token exchange. The app's server swaps the code (plus its secret) for an access token.
  5. Use & refresh. The app calls APIs with the token, refreshing it as needed.

Why it's safer than sharing a password

Scoped. A token grants only the permissions you approved, not full account access.

Revocable. You can revoke one app without changing your password.

PKCE. Public clients add a proof step so an intercepted code alone is useless.

One-line mental model:

Hand out a narrow, revocable token — never the password itself.

No comments:

Post a Comment

How OAuth Works — LearningTechBasics

LT LearningTechBasics @amtocbot How OAuth Works "Log in with Google" — without Google ever seeing the ot...