Glossary

PKCE (Proof Key for Code Exchange)

A one-time secret that makes stolen authorization codes useless. PKCE lets mobile apps and single-page apps complete OAuth sign-in safely without a client secret, and is now recommended for every client.

General definition

PKCE (Proof Key for Code Exchange), pronounced “pixy”, is defined in RFC 7636 (2015) as a security extension to the OAuth 2.0 authorization code grant. It was designed for public clients, meaning native mobile apps and browser-based single-page applications that cannot keep a client secret, where an attacker on the same device could register the app’s custom URL scheme or read the redirect and capture the authorization code. PKCE binds the code to the client instance that requested it, so an intercepted code cannot be exchanged for tokens.

The flow adds two values to the standard authorization code exchange:

  • The client generates a random code verifier, a string of 43 to 128 characters, and keeps it in memory
  • It derives a code challenge by hashing the verifier with SHA-256 and base64url-encoding the result (method S256; the plain method is allowed but discouraged)
  • The authorization request carries code_challenge and code_challenge_method; the server stores them with the issued code
  • The token request carries the original code_verifier; the server hashes it, compares it to the stored challenge, and only then returns the access token

Because the verifier never travels through the browser or redirect, an attacker who captures only the code cannot complete the exchange. RFC 8252 (OAuth 2.0 for Native Apps) recommends PKCE for all native apps, and the OAuth 2.1 draft, which consolidates current best practice, requires PKCE for every client using the authorization code flow, confidential clients included, because it also defends against authorization code injection. OpenID Connect runs on the same flow, so PKCE applies to sign-in with Google, Apple, Microsoft and other identity providers, and the Model Context Protocol authorization specification adopts OAuth 2.1 with PKCE for remote MCP servers.

PKCE is not a replacement for TLS, for validating the state parameter against cross-site request forgery, or for exact redirect URI matching; it closes one specific gap, and the others still need closing.

Need full control of the stack? Ethora runs as a self-hosted chat server on premise, in your own cloud or from AWS Marketplace.

In the Ethora ecosystem

Ethora delegates user authentication rather than reinventing it. Social sign-on through Google, Apple, Facebook and other providers uses the providers’ OAuth and OIDC flows, where PKCE is handled by the provider SDK or by your own backend when you run the authorization code exchange yourself. If you provision end users from your backend through the Ethora API, your application performs sign-in with your identity provider using PKCE and then requests a short-lived JWT chat token for that user, so the chat SDK never holds your OAuth credentials.

Server-to-server access, such as creating users or rooms from your backend, uses an app-level API token that stays on the server, which is the confidential-client case PKCE was not originally designed for. For MCP clients connecting to the Ethora MCP server over Streamable HTTP, the authentication model is documented on the MCP server authentication page.

Get started

Run chat and AI on servers you control

An open-source chat server on premise, in your own cloud or from AWS Marketplace, with an enterprise SLA.

Free tier available Enterprise SLA No vendor lock-in