Skip to content

Glossary

PKCE (Proof Key for Code Exchange)

PKCE (RFC 7636) binds an OAuth authorization code to the client that asked for it, so a stolen code is useless. Public clients and MCP agents depend on it.

PKCE, short for Proof Key for Code Exchange and pronounced "pixy", is an extension of the OAuth authorization code flow defined in RFC 7636. It makes sure that the client redeeming an authorization code is the one that started the sign-in.

How it works

  1. Before sending the user to the authorization server, the client creates a random secret, the code_verifier.
  2. It sends a code_challenge derived from it. With the S256 method, the challenge is the base64url-encoded SHA-256 hash of the verifier. RFC 7636 says a client capable of S256 must use it rather than plain.
  3. When the client exchanges the code for tokens, it sends the original code_verifier. The server hashes it and compares it with the challenge it stored.

Someone who intercepts the authorization code cannot redeem it without the verifier, which never left the client.

Why public clients need it

Mobile apps, single-page apps, CLIs and AI agents cannot keep a client secret, so they are registered as public clients. For them, PKCE is what ties the code to the client. In Ostiary, clients that register themselves through Dynamic Client Registration or a metadata document may only use the authorization code flow with PKCE, and anonymous registrations always produce public clients. OAuth for MCP clients and AI agents explains why, and the OpenID Connect provider guide shows where PKCE fits into a sign-in with OpenID Connect.