Use this when apps need delegated API access without user passwords.
OAuth 2.0
OAuth 2.0 is an authorization framework that lets an application get limited access to an API on a user's behalf through access tokens, without handling the user's password. Use authorization code with PKCE.
1. OAuth 2.0 delegates authorization via access tokens.
2. Use authorization code + PKCE.
3. No implicit flow.
4. Exact redirect URI matching.
5. Least-privilege scopes; short-lived tokens.
client → authorize (code + PKCE) → token → API
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Known-good, broken and when it is fixed Verify boundary
Known-good means the intended client obtains a token through the approved flow, the token is constrained to expected issuer/audience/scope/lifetime, the resource server accepts it for an allowed operation and rejects an out-of-scope operation. HTTP success at the token endpoint shows issuance only; protected-resource behavior closes delegated authorization.
Step 2 Native failure isolation and next-check logic Narrow the fault
Identify client ID, grant/flow, requested scopes, redirect URI, token audience/resource and the failing resource request. For authorization failures, distinguish authorization-endpoint errors from token-endpoint errors and resource-server rejection. Inspect token claims/metadata without treating them as authoritative unless signature/issuer/audience validation is performed by the resource server. If a token is valid but access is denied, inspect resource policy and scope-to-permission mapping.
Step 3 Common mistakes Narrow the fault
- Using OAuth tokens as evidence of identity (use OIDC ID tokens).
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
- Use authorization code flow with PKCE.
- Implicit flow is deprecated.
- Tokens must be scoped minimally.
curl -s https://<as>/.well-known/oauth-authorization-server— metadata- Registered redirect URIs — exact match
- Granted scopes per client — least privilege
ReferenceWhat it is1 section · depth on demand
Scope and canonical references
This is the canonical OAuth 2.0 Topic: roles, grants, tokens and security best practice.
- Calling APIs from scripts and automation with OAuth: OAuth 2.0 under Automation → APIs — client setup, token handling in code.
- Sign-in (identity) on top of OAuth: OpenID Connect.
- Token types: Access Token, Refresh Token, ID Token.
- Products that implement it: Microsoft Entra ID, Keycloak.
ReferenceHow it works1 section · depth on demand
How it works
OAuth 2.0 delegates authorization using clients, authorization server, resource owner context and access tokens scoped to protected resources. Grant/flow selection determines how the client obtains tokens; scopes and audience/resource indicators define intended use. Token issuance shows authorization-server processing, not that a resource server will accept the token for a particular action.
ReferenceImportant terms & boundaries2 sections · depth on demand
In depth
OAuth 2.0 is an authorisation framework that lets a client application obtain limited access to an API on behalf of a user or itself, via access tokens issued by an authorisation server. It is about delegated authorisation, not authentication (that is OpenID Connect's role).
| Grant / flow | Use |
|---|---|
| Authorization code + PKCE | Web, mobile and single-page apps (recommended) |
| Client credentials | Machine-to-machine |
| Device authorization | Devices without browsers (CLI tools, TVs) |
| Refresh token | Renew access without user interaction |
| Implicit, password | Deprecated — do not use |
Security essentials: exact redirect URI matching, PKCE for all public clients, minimal scopes, short-lived access tokens, protected client secrets (or certificate/private_key_jwt), and OAuth 2.1 / security BCP guidance.
Security best practice (RFC 9700)
RFC 9700 (January 2025, BCP 240) is the IETF's current security guidance for OAuth 2.0 and updates RFC 6749, 6750 and 6819. The points that change everyday configuration:
| Recommendation | What to do |
|---|---|
| Authorization code + PKCE | Public clients must use PKCE; confidential clients should. Use S256. Servers must enforce the verifier when a challenge was sent. |
| No implicit grant | Do not return access tokens from the authorization endpoint (response_type=token). |
| No password grant | The resource owner password credentials grant must not be used. |
| Exact redirect URIs | Servers compare redirect URIs by exact string match (only the port of localhost may vary for native apps). No wildcards. |
| Refresh tokens | For public clients, refresh tokens must be sender-constrained or rotated on every use. |
| Sender-constrained tokens | Prefer mTLS (RFC 8705) or DPoP (RFC 9449) and restrict token audience. |
For unattended machine-to-machine access use the client credentials grant with a certificate or private-key JWT rather than a shared secret where the IdP supports it.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Single Sign-On & Federation → OAuth 2.0. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://www.rfc-editor.org/rfc/rfc7522 · confidence 94%Terms & aliases
Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.