Explain the OAuth 2.0 Authorization Code flow with PKCE. Why was the Implicit flow deprecated?
Authorization Code + PKCE is the recommended flow for public clients (SPAs, mobile apps) that cannot safely hold a client secret.
How PKCE works:
- The client generates a random
code_verifier(≥43 chars) and computescode_challenge = BASE64URL(SHA-256(code_verifier)). - The authorization request includes
code_challengeandcode_challenge_method=S256. - The server stores the challenge; on successful login, it issues an authorization
code. - The client exchanges the
code+ the originalcode_verifierfor tokens. The server verifies thatSHA-256(verifier) == stored_challenge— only the client that started the flow can complete it.
Why this matters: Without PKCE, if an attacker intercepts the authorization code (via a redirect URI mismatch, an open redirect, or a browser history leak), they can exchange it for tokens. PKCE ensures code interception is useless without the verifier.
Why Implicit was deprecated (RFC 9700):
- The Implicit flow returned access tokens directly in the URL fragment (e.g.
#access_token=...) — exposed in browser history, referrer headers, and server logs. - No refresh token was issued, and tokens couldn't be bound to a specific client.
- PKCE makes Authorization Code safe for public clients, eliminating the need for Implicit entirely.