# OAuth 2.0

A delegated authorization framework that lets a client obtain limited access to protected resources without receiving the resource owner's credentials.

- Type: framework
- Domain: Engineering & architecture
- Level: Intermediate
- Last reviewed: 2026-09-23
- Original: [Soroush’s Product Wiki](<https://wiki.soroush.uk/topic/oauth-2-0/>)

## What 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.

## Why 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.

## When 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.

## How it works

1. Register the client, redirect URIs, allowed flows, and trust assumptions.
2. Send the resource owner to the authorization server with state, scope, and PKCE parameters.
3. Authenticate and authorize at the authorization server, then return a short-lived authorization code.
4. Exchange the code and verifier for an access token through a protected back channel.
5. Present the token to the resource server, which validates it and enforces audience and scope.
6. Expire, rotate, revoke, and monitor tokens according to risk.

## A 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.

## Where 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.

## Visualization

[View the visualization on the website](<https://wiki.soroush.uk/topic/oauth-2-0/#visualization-oauth-2-0>)

## Sources

1. [The OAuth 2.0 Authorization Framework \(RFC 6749\)](<https://www.rfc-editor.org/rfc/rfc6749>) — RFC Editor · Internet Standard
2. [Best Current Practice for OAuth 2.0 Security \(RFC 9700\)](<https://www.rfc-editor.org/rfc/rfc9700>) — RFC Editor · Best Current Practice

## Related topics

- [Authorization](<https://wiki.soroush.uk/topic/authorization/>)
- [OpenID Connect \(OIDC\)](<https://wiki.soroush.uk/topic/openid-connect/>)
- [JSON Web Token \(JWT\)](<https://wiki.soroush.uk/topic/json-web-token/>)
