OAuth 2.0
A delegated authorization framework that lets a client obtain limited access to protected resources without receiving the resource owner's credentials.
Download Markdown (.md)Soroush’s Product Wiki · https://wiki.soroush.uk/topic/oauth-2-0/
01What it means
OAuth 2.0 defines roles and protocol flows for issuing access tokens to clients. A resource owner authorizes a client through an authorization server, and the client presents a scoped token to a resource server. OAuth delegates authorization; by itself it does not authenticate a user to the client.[1][2]
- 01ClientRequests authorization + PKCE
- 02Resource ownerAuthenticates and authorizes
- 03Authorization serverReturns short-lived code
- 04Token exchangeCode + verifier
- 05Resource serverValidates audience and scope
OAuth issues authorization tokens; it does not authenticate the user to the client.
02Why it matters
OAuth allows users and organizations to grant bounded, revocable access without sharing passwords. Correct flows separate clients, authorization servers, and APIs while supporting scope, consent, token lifetime, and modern application types.
03When to use it
Use OAuth when an application needs delegated API access or centralized token issuance across services. Use OpenID Connect when the client also needs a standardized login identity, and avoid OAuth overhead for a simple first-party session with no delegation need.
04How it works
- Register the client, redirect URIs, allowed flows, and trust assumptions.
- Send the resource owner to the authorization server with state, scope, and PKCE parameters.
- Authenticate and authorize at the authorization server, then return a short-lived authorization code.
- Exchange the code and verifier for an access token through a protected back channel.
- Present the token to the resource server, which validates it and enforces audience and scope.
- Expire, rotate, revoke, and monitor tokens according to risk.
05A practical example
A scheduling app asks a user for read-only calendar access. The calendar provider authenticates the user, records consent, and issues a scoped access token; the scheduling app never handles the user's calendar password.
06Where it breaks
OAuth is a framework with security-sensitive choices, not a single turnkey protocol. Tokens can be stolen, scopes can be too broad, and browser or mobile clients require careful redirect, PKCE, and storage design.
Common mistakes
- Using OAuth access tokens as proof that a user logged in to the client.
- Using deprecated implicit or resource-owner password flows.
- Failing to validate redirect URIs, state, issuer, audience, and PKCE.
- Issuing broad, long-lived bearer tokens without rotation or revocation.
07Sources
- The OAuth 2.0 Authorization Framework (RFC 6749)RFC Editor · Internet StandardThe OAuth 2.0 Authorization Framework (RFC 6749)
- Best Current Practice for OAuth 2.0 Security (RFC 9700)RFC Editor · Best Current PracticeBest Current Practice for OAuth 2.0 Security (RFC 9700)