🔑JWT & Auth
PKCE Code Verifier
Securing mobile and single-page apps during OAuth flow.
Explanation
PKCE prevents authorization code injection attacks by requiring a secret "challenge" verified at exchange.
Examples
Flow
Output
Verifier -> Challenge (SHA256) -> Exchange
Code Examples
JavaScript
// 1. Generate Verifier (random string)
const verifier = generateRandomString(64);
// 2. Create Challenge
const challenge = crypto.createHash('sha256')
.update(verifier)
.digest('base64url');💡 Tips
- Required for modern mobile and SPA apps
- The verifier must be between 43 and 128 characters
- Use "S256" as the code_challenge_method
⚠️ Common Pitfalls
- Using the "plain" method which is less secure