Identity & access

PKCE

Proof Key for Code Exchange

An OAuth extension (RFC 7636) that binds an authorisation code to the client that requested it, so a stolen code is useless.

With PKCE the client generates a random code_verifier, sends code_challenge = BASE64URL(SHA256(code_verifier)) with code_challenge_method=S256 in the authorisation request, then presents the original verifier when exchanging the code. An attacker who intercepts the code (malicious app on the same custom URL scheme, leaked logs) cannot redeem it without the verifier.

Designed for mobile and single-page apps that cannot hold a client secret, it is now recommended for every client, confidential ones included, by RFC 9700 and OAuth 2.1. It also protects against code injection.

Mistakes: using the plain method, reusing a verifier, or an authorisation server that accepts the exchange without a verifier when a challenge was sent.

Learn it properly

Compared

Also used in

Related terms