Proof Key for Code Exchange (RFC 7636) — the modern, browser-safe OIDC flow for public clients (Single Page Applications and Mobile Apps). No client secret is used; cryptography executed in the browser guarantees that only the client that initiated the request can redeem the authorization code.
PKCE prevents the Authorization Code Interception Attack where a malicious actor or extension snoops the redirect URL to steal the auth code. Here is the step-by-step cryptographic sequence:
code_verifier)
using crypto.getRandomValues(). It then hashes this verifier using SHA-256 and base64url-encodes
the digest to produce the code_challenge. The verifier stays safely in the browser's local memory.
GET /authorize):
The browser redirects the user to the IdP's login page, appending response_type=code,
code_challenge, and code_challenge_method=S256.
The IdP authenticates the user, records the challenge with the session, and prompts for consent.
redirect_uri with an authorization
code in the query string. Even if an attacker intercepts this code in browser history, they cannot
use it without the unhashed verifier.
POST /token):
The browser makes a direct HTTP POST (via fetch) to the token endpoint, presenting the
code and the original plain code_verifier.
The IdP computes SHA256(code_verifier): if the hash matches the recorded challenge, it confirms
the caller is authentic and issues tokens.
id_token (JWT asserting the user's identity) and an access_token
(bearer token for API calls).
Enter your OpenID Connect provider details. Values are saved to sessionStorage and update the live request previews.
openid is mandatory to request an ID token; profile and email request user claims.| Key | Value |
|---|
Generates a cryptographically secure random code_verifier (32 random bytes converted to hex, 256 bits of entropy),
then computes the code_challenge as BASE64URL(SHA-256(code_verifier)).
Also generates a unique state token to guard against Cross-Site Request Forgery (CSRF).
// Click Generate Keys to run window.crypto.subtle.digest('SHA-256', ...)
The user's browser redirects to the IdP's authorization endpoint. Notice how the code_challenge
is passed in the query string, while the plain code_verifier remains stored safely in the browser.
// Fill in config above to preview the Authorization URL
After successful login and consent, the IdP redirects back to the redirect_uri with a short-lived,
single-use code and returns the matching state parameter.
// Awaiting redirect from IdP…
The browser sends a direct HTTP POST to the token endpoint containing the code and
the plain code_verifier. The IdP verifies that SHA256(code_verifier) == code_challenge,
guaranteeing that the entity redeeming the code is the same client that initiated the flow.
// Waiting for Step 4…
IdP Token Response
// Awaiting token exchange…
Explore the contents of the returned tokens. The id_token contains user identity claims
(sub, email, name) signed by the IdP.
The access_token authorizes calls to downstream protected APIs.