authorization code flow
The OAuth flow in which the browser brings back a short-lived code that the client then exchanges directly with the authorization server for tokens.
In more detail
The tokens never pass through the browser address bar. The client checks the state value, uses PKCE, and the redirect goes only to a pre-registered redirect URI.
Related terms
- PKCE — Short for Proof Key for Code Exchange: the client sends a hash of a random secret at the start of the flow and the secret itself when exchanging the code.
- redirect URI — The address an authorization server sends the browser back to, with the result, after the user signs in and consents.
- state parameter — A random value the client sends at the start of an OAuth flow and checks when the browser returns, binding the response to its own request.
- OAuth 2.0 — A framework for delegated authorization: a user lets an application call an API on their behalf without giving it their password.
- implicit grant — An old OAuth flow that returned access tokens directly in the browser redirect, now deprecated because tokens could leak.
Taught in
- Remote Servers And Trust — AI Engineering: LLM Apps, RAG & Agents
- OAuth Two And OpenID Connect — Modern API Architecture: REST, GraphQL & gRPC
- OAuth2 & OpenID Connect: Social Auth & PKCE Flows — Production Full-Stack Engineering
References
- RFC 6749: The OAuth 2.0 Authorization Framework
- RFC 9700: Best Current Practice for OAuth 2.0 Security
- RFC 6749: Authorization code grant