Architectural Breakdown & AnalysisFAANG Aligned
Public clients (React SPAs, Mobile Apps) cannot securely store Client Secrets. Standard Authorization Code Grant exposes them to interception attacks.
How PKCE Prevents Interception
- Code Verifier Generation: App generates a random high-entropy string (
code_verifier). - Code Challenge Creation: App hashes the verifier using SHA-256 (
code_challenge = Base64(SHA256(code_verifier))). - Authorization Request: Client sends user to Auth Server with
code_challengeandcode_challenge_method=S256. - Token Exchange: When Auth Server returns the
authorization_code, the app sends the originalcode_verifier. Auth Server hashes it and verifies match before issuing JWT tokens.
TIP — Security Standard
OAuth 2.0 Security Best Practices mandate PKCE for all SPA and mobile application authentication flows.
Key Architectural Comparison
| OAuth 2.0 Flow | Security Vulnerability | Client Type | Token Exposure Risk | Modern Status |
|---|---|---|---|---|
| Implicit Grant | Access token returned directly in URL hash. | SPAs & Mobile. | High (Token leaked in browser history/logs). | Deprecated & Banned. |
| Auth Code (with Secret) | Secret cannot be hidden on public clients. | Backend Web Apps. | Low (Token exchanged backchannel). | Standard for server-side apps. |
| Auth Code + PKCE | Cryptographic code verifier / challenge. | SPAs & Mobile. | Zero (Intercepted auth codes cannot be exchanged). | Current Industry Standard. |