OAuth 2.0 Grant Types: Implicit and PKCE
You'll learn how two OAuth 2.0 flows address the security challenges of public clients that can't keep secrets—like single-page apps and mobile apps.
The Implicit Grant (Deprecated)
The Implicit Grant was designed for JavaScript apps running in browsers where keeping client secrets secure is impossible. Unlike the Authorization Code Grant you learned previously, the implicit flow skipped the code exchange step entirely—the access token was returned directly in the URL fragment after user authorization.
Think of it like ordering food delivery: instead of getting a claim ticket to exchange for your meal (authorization code), the delivery person just hands you the food immediately on your doorstep, visible to anyone watching.
The problem? Tokens appeared in browser history, could be intercepted by malicious scripts, and offered no way to verify the client's identity. This flow is now deprecated and should not be used.
PKCE: The Modern Solution
PKCE (Proof Key for Code Exchange, pronounced "pixy") extends the Authorization Code Grant for public clients. It adds a cryptographic challenge to prevent token interception, even when the client can't authenticate itself.
Here's how it works:
- The client generates a random code verifier (a secret string)
- It hashes that verifier to create a code challenge and sends it with the authorization request
- After receiving the authorization code, the client sends the original code verifier when exchanging it for tokens
- The authorization server verifies the verifier matches the original challenge
Even if an attacker steals the authorization code, they can't exchange it without the original code verifier—which never left the client.
Key Takeaway: The Implicit Grant is deprecated due to security flaws; use PKCE-enhanced Authorization Code Grant for all public clients like SPAs and mobile apps—it provides cryptographic protection without requiring client secrets.