A browser round trip, protected by PKCE
02Proof Key for Code Exchange (PKCE) lets an installed app prove it knows a fresh secret when exchanging a code.
Alternative branch: the callback reaches the original app. It submits code C with its secret; the issuer checks the challenge and returns a separate access token.
Key idea: An intercepted code should be unusable alone.
Terms
- Original app / client
- The installed app requesting access. A public client cannot rely on a shared secret embedded in every app copy as proof of its identity.
- Verifier and challenge
- The verifier is a fresh secret for one authorization attempt. The challenge is a value derived from it and sent first.
- S256
- A SHA-256 hash with base64url encoding derives the challenge. The issuer repeats this operation on the submitted secret and compares the result.
- Code C and token T
- Illustrative names: the temporary code is exchanged for a separate access credential. They are not passwords.
- Two callback outcomes
- The interception and legitimate-delivery scenes are alternatives starting from the same setup. The original app is not shown recovering an intercepted callback.
- Limits
- PKCE binds the exchange to a fresh secret. It does not encrypt the callback or replace redirect checks, secure transport, or all app-identity and transaction checks.
Rules & examples
An intercepted code should be unusable alone.
- Public native apps MUST implement PKCE, and authorization servers MUST support it for them.
- Generate a fresh verifier and send the corresponding challenge with the initial request.
- Servers SHOULD reject native-app authorization requests that omit PKCE (§ 8.1).
RFC 9700 later extends explicit PKCE requirements across public OAuth clients, not just native apps.
Sources
New to this? Start hereA quick picture + helpful background
A key is different from permission.
An app, a person, and a server have different roles. Follow who asks, who grants permission, and who checks the credential. A key in the drawing is an analogy, not a literal protocol field.
Helpful first, if these ideas are unfamiliar
These pictures are analogies to help you learn. The linked RFC explains the actual rules.
Related RFCs and changes
“Updates” changes part of an earlier RFC. “Obsoletes” replaces it. This list shows selected related documents.
The later BCP explicitly requires PKCE for all public clients and recommends it for confidential clients, with downgrade prevention at the server.
Read the updated RFC section ↗