DevTools Logo

OAuth 2.0 PKCE Helper

OAuth 2.0 PKCE Helper

Generate verifier/challenge pairs, build authorize URLs and check redirects — all in this tab.

Runs in your browser
Try an example

PKCE session

no session

Session card

no session

Server-side token exchange (guidance only)

curl -X POST 'https://YOUR_TENANT.auth0.com/oauth/token' \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -d 'grant_type=authorization_code&code=AUTHORIZATION_CODE&redirect_uri=https%3A%2F%2Flocalhost%3A3000%2Fcallback&client_id=YOUR_CLIENT_ID&code_verifier=CODE_VERIFIER'

Never paste a client secret into a browser tool; run this exchange on your backend.

Details

PKCE (RFC 7636) protects authorization-code flows for public clients: the browser creates a 43–128 character verifier, derives a base64url SHA-256 challenge and sends only the challenge to the authorize endpoint. This helper generates the pair with cryptographic randomness, builds the full authorize URL — including the easily forgotten code_challenge_method=S256 parameter — and verifies the state returned in query or fragment redirects. The deprecated plain method is available for compatibility and clearly flagged. Nothing is persisted: the session card lives in memory and resets on reload. Token exchange is deliberately not performed; a server-side curl template is shown as guidance only, and no client secret field exists.

More examples

RFC 7636 Appendix B vector

verifier: dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk
challenge: E9Melhoa2OwvFrEMTJguCHaoeK1t8URWbuGJSstw-cM

The exact standard test vector confirms S256 = base64url(SHA-256(verifier)).

Authorize URL for a SPA

endpoint: https://accounts.google.com/o/oauth2/v2/auth
client_id: example-client.apps.googleusercontent.com
scope: openid email profile → URL with code_challenge and code_challenge_method=S256

The builder always includes the challenge method, which RFC 7636 otherwise defaults to plain.

Redirect with state mismatch

https://app.example/cb#code=abc123&state=other → FAIL — state mismatch; possible CSRF

Fragment-mode responses are parsed just like query responses, and state is compared against the current session.

Examples

RFC vector

Input
verifier = dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk
Output
challenge = E9Melhoa2OwvFrEMTJguCHaoeK1t8URWbuGJSstw-cM

The normative RFC 7636 Appendix B pair verifies the S256 derivation.

Authorize URL

Input
endpoint + client_id + redirect_uri + scopes + session values
Output
https://provider/authorize?response_type=code&…&code_challenge_method=S256

The challenge method is always present so strict providers accept the request.

State mismatch

Input
redirect #state=other vs session state
Output
FAIL — state mismatch; possible CSRF

Strict string comparison is enough for a debugging aid; real clients also bind state to a server-side session.

About this tool

OAuth 2.0 PKCE Helper is a workbench for the pre-token part of an authorization-code flow. It generates a cryptographically random code verifier (32, 64 or 96 bytes, base64url-encoded to 43, 86 or 128 characters), derives the S256 challenge with SHA-256, and shows both values alongside the state and nonce your session must carry across the redirect.

The Build URL tab assembles an authorization request with response_type=code, client_id, redirect_uri, scopes, state, nonce, prompt and other extras. It always emits code_challenge and code_challenge_method — the method parameter matters because RFC 7636 defaults to the deprecated plain method if it is missing. Scopes are separated by spaces and encoded as %20 rather than form-encoded plus signs.

The Parse redirect tab accepts a query or fragment response, lists all returned parameters, and compares state with your current session: PASS, FAIL, MISSING or NO SESSION. Provider error responses such as access_denied are surfaced with their error_description while state is still checked.

Everything is local and in-memory. The verifier and state are deliberately never written to localStorage; reloading starts a new session. A server-side curl template is shown for guidance, but this tool cannot and does not exchange the authorization code for a token.

What this tool does not do

  • No token exchange is performed and no client secret is accepted; that step requires a trusted backend.
  • Sessions are in-memory only and intentionally lost on reload.
  • State comparison is a strict string equality check suitable for debugging, not a replacement for server-side CSRF binding.
  • Provider presets contain public endpoint templates only; credentials must be supplied by the user.

How to use this tool

  1. Generate a session

    A verifier/challenge pair is created on load. Choose 32, 64 or 96 bytes of entropy, or paste a custom RFC-valid verifier and click Use this verifier.

  2. Copy the pair

    Copy the verifier and challenge into your client implementation. Keep the verifier: it must be replayed at the token endpoint later.

  3. Build the authorize URL

    Enter the provider's authorize endpoint, client_id, redirect_uri and scopes. State and nonce default to your session values; then copy the generated URL.

  4. Parse the redirect

    After login, paste the full redirect URL. Query and fragment responses are auto-detected, and the state verdict tells you whether the response belongs to this session.

Use cases

SPA debugging

Reproduce Auth0, Cognito, Google or Azure authorize requests with a fresh, correctly paired challenge.

Mobile redirect testing

Paste a callback URL from a device and confirm code, error and state values.

Security review

Inspect whether a provider's flow sends state, nonce and S256 as required.

Integration docs

Copy an exact authorize URL and query-breakdown table into a ticket.

PKCE values and URL parameters

FieldRule / example
code_verifier43–128 chars from [A-Za-z0-9-._~], e.g. dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk
code_challengebase64url(SHA-256(verifier)), 43 chars for S256
code_challenge_methodS256 (recommended) or plain (deprecated)
state / nonce16 random bytes base64url-encoded; state is CSRF-bound, nonce is OIDC-bound
scopeSpace-separated list; encoded as %20 in the URL

The token exchange itself is server-side only; no client secret field exists in this tool.

Common mistakes

Mistake:Omitting code_challenge_method=S256.

Fix:RFC 7636 defaults to plain when the parameter is absent; this builder always emits it.

Mistake:Using a verifier shorter than 43 characters.

Fix:Generate one with the tool or check the RFC 7636 §4.1 charset and length rules.

Mistake:Exchanging the code in browser JavaScript.

Fix:Run the token exchange on a backend; the curl panel is guidance only.

Mistake:Treating a FAIL verdict after a reload as definitive CSRF.

Fix:The session is in-memory by design; a reload creates a new state, so restart the flow.

Mistake:Comma-separating OAuth scopes.

Fix:Scopes are space-separated; the builder converts commas and whitespace to individual scopes.

Frequently asked questions

How long must a code verifier be?

RFC 7636 requires 43–128 characters drawn from A–Z, a–z, 0–9, hyphen, dot, underscore and tilde. The generator uses 32 random bytes by default (43 base64url characters) and can use 64 or 96 bytes for more entropy.

Is the challenge SHA-256 or plain?

The recommended S256 method is base64url(SHA-256(verifier)). Plain sends the verifier itself and is deprecated; this tool supports it only for compatibility and shows a warning when selected.

Where should state be validated?

Your client should compare the returned state with the value it stored before redirecting. This tool reports PASS/FAIL as a debugging aid, but production CSRF binding must happen in your application session.

Why can't this tool exchange the code for a token?

A token exchange normally requires client authentication (a secret or signed assertion) and should run on a trusted backend. This tool only generates, builds and parses; the curl panel is a template for your server.

Is storing the verifier in localStorage safe?

It is avoidable: this tool keeps the verifier and state in memory only, so they disappear on reload. If your client persists them, use the shortest practical lifetime and never write client secrets to browser storage.

What does NO SESSION mean in the parse tab?

It means no state was generated in this tab yet, often because the page was reloaded between starting and finishing the flow. Start a new flow so the verifier and state stay paired.

References & standards