concept Security & reliability
OAuth PKCE binding during authorization-code exchange
PKCE binds an authorization code to a request-specific verifier. See why the code alone is not enough, and why even a matching verifier does not guarantee a token.
What it means
In an OAuth authorization-code flow that uses Proof Key for Code Exchange (PKCE), having the code is not enough to exchange it for a token. The client must also present the verifier it kept for that particular request. With the S256 method, the authorization server transforms the verifier and compares the result with the challenge it stored for the code.
Consider a public client: the server cannot rely on it to keep a long-lived client secret confidential. PKCE asks a narrower question: does the client exchanging this code have the verifier associated with the request that produced it?
Try it
Simulation — use only the supplied choices. Do not paste a real code or verifier or test a live endpoint. The example starts with an unused authorization code, a client/redirect match, a verifier match of yes, and scenario evidence provided. The result is eligible: all the checks represented here pass. No token has been issued.
OAuth PKCE binding during authorization-code exchange
Explain challenge/verifier binding and request identity in a public client
All modeled exchange bindings pass; other authorization-server checks remain.
Stipulated exchange checks
- Code stateunused
- Client / redirect bindingmatch
- Verifier matches stored challengeyes
Exchange result
- OutcomeSelected checks pass — token not issued
An absent verifier in a real token request is not a control in this model. Unknown relation means missing observation. Code and client conditions can stop evaluation before proof matching; no token is issued.
Evaluated inputs
- Required scenario evidence
- provided
- Authorization code
- unused
- Client/redirect binding
- match
- Verifier matches stored challenge
- yes
Symbolic S256 relation; no real secrets, tokens, challenge generation, endpoint calls or bypass.
About this model
The controls set only a local, bounded scenario. The computed branch is not a verdict about a live system. Inputs listed as not evaluated did not participate in this branch after validation.
Reset restores the original inputs. It does not change the open or closed state of help or FAQ answers.
Change only Verifier matches stored challenge from yes to no. The code is still unused and the client/redirect binding still matches. The result changes to deny because the transformed verifier does not match the challenge stored for this code.
Use Reset to restore all four starting choices. Now change only Authorization code to used. The result is also deny, but for a different reason: the code has already been used. The simulation stops at that check. Although the verifier choice still says yes, the model did not evaluate it. Reset returns to the initial eligible example.
What travels in each request
- Authorization request: The client keeps a request-specific verifier and sends the challenge derived from it. With S256, the challenge and verifier are not the same string.
- Redirect back to the client: The authorization server associates the challenge and its method with the code. It redirects the browser to the client with the authorization code. The redirect delivers a code, not a token. If the client sent OAuth
state, the response returns that value. Checking the callback against the pending request is separate from the PKCE proof. Follow the flow’s applicable CSRF protection requirements, rather than treating a matching verifier as a universal callback check. - Code exchange: The client sends the code and its retained verifier to the token endpoint. The server uses the challenge associated with that code for the comparison. A verifier from a different request that produces a different challenge will not work, even for the same client.
A match establishes only the PKCE part of the exchange. It does not validate the redirect destination or determine what permissions to grant. The server still has to validate the code and its binding to the client. If the authorization request included redirect_uri, the corresponding value in the token request must be identical.
The exchange diagram covers only the code-exchange decision. It does not show whether the earlier callback was associated with the pending request, whether state was supplied, or whether the redirect was accepted.
In practice
Distinguish a missing proof from a missing observation. If a code has an S256 challenge and the client sends no verifier, the required proof is absent. If you simply do not know whether the verifier matched, you have not established either a match or a mismatch. In the simulation, an unused code and matching client/redirect binding with the verifier relation set to unknown give unknown, not deny. Setting the scenario evidence to missing goes further: none of the exchange checks are evaluated.
When reviewing a flow, first identify which step the evidence describes. A browser arriving at the client with a code tells you nothing about the later verifier comparison. A confirmed verifier match tells you nothing about whether the code was already used. If the necessary facts or the applicable service version are unknown, stop rather than changing a real configuration on the strength of this example. A matching PKCE proof satisfies one exchange condition; it is not a verdict on the whole exchange.
Frequently asked questions
Editorial questions based on the listed sources and explicitly labeled local examples.
Is PKCE a client secret?
No. PKCE uses a request-specific verifier and challenge; it is not a long-lived client-authentication secret. Follow the authorization server’s separate client rules.
Does it replace redirect URI validation?
No. PKCE binds code exchange to the associated challenge, while redirect URI validation addresses a separate authorization request boundary. Apply both requirements appropriate to the flow; a valid verifier does not validate the redirect destination.
Is the verifier sent in the authorization request?
The challenge is sent there; verifier at exchange.
Does a matching verifier alone authorize exchange?
No. A successful proof comparison permits the ordinary exchange checks to continue. The code must also be valid and bound to the appropriate client, and the redirect URI must match when it was supplied in the authorization request. This symbolic example issues no token.
Sources & model boundaries
Primary references used for this explanation. The interactive example is an educational model, not a live check.
- RFC 7636: Proof Key for Code Exchange by OAuth Public Clients
4.3–4.6. The authorization code is associated with its challenge and transformation method; the exchange compares the supplied verifier under that method. A match permits ordinary processing to continue.
Checked .
- RFC 9700: Best Current Practice for OAuth 2.0 Security
Sections 2.1 and 2.1.1. PKCE guidance extends to all client types. S256 and redirect URI validation address separate security requirements.
Checked .
- RFC 6749: OAuth 2.0 Authorization Framework
2.1; 4.1.1–4.1.3. Public client type concerns secure client authentication; state is returned if supplied. Code validity, client binding and conditional redirect URI matching are separate token-exchange checks.
Checked .