The authorization code flow
The authorization code flow step by step: the request, consent, the returned code, PKCE and exchanging the code for tokens.
Start with Why use the authorization code flow?
- Why use the authorization code flow?See how URLs leak through history, logs, the Referer header and shared links, why the code flow returns only a code through the browser, and follow one connection from registration to the first API call.
- The authorization requestRead an OAuth authorization request and understand client IDs, redirect URIs, scopes, state, and PKCE challenges.
- Redirects and authorization codesUnderstand exact redirect URI matching, authorization responses, and safe handling of short-lived authorization codes.
- Proof Key for Code Exchange (PKCE)Follow the PKCE verifier and challenge calculation, and see how binding code redemption to one attempt also stops code injection against confidential clients.
- Correlating requests and responsesConnect OAuth responses to their initiating session, pending transaction, and expected authorization server, and see how those checks stop CSRF and mix-up attacks.
- Exchanging a code for tokensRead an authorization code token request and response, including client authentication, PKCE, and access token use.
- Errors and denied accessDistinguish OAuth authorization denial, token endpoint rejection, and uncertain network outcomes.