Beta

Create a tenant

A new tenant starts with its own users, OAuth settings, audit history and logs. You are its first Tenant Admin.

Binding a token to a key

A bearer token works for anyone who holds a copy. Demonstrating Proof of Possession, or DPoP, binds a token to a key pair the client generated, so the token is accepted only beside a fresh proof signed with the private key. This lesson follows the printer's phone app as it binds Ava's tokens to a key that never leaves her phone.

A token that needs its key

Ava Archer, whose account at the photo service is user-2048, uses the printer's phone app, photo-printer-app, to order prints from her albums. The app holds an access token for the photo API and a refresh token for getting the next one. Token theft and replay followed the ways a token like that escapes: a debugging log, a backup, a proxy that records headers. It ended with the alternative to a bearer token, a sender-constrained token, which the API accepts only from a sender who can prove possession of a particular key.

Demonstrating Proof of Possession, shortened to DPoP and published as RFC 9449, is one standard way to build that binding. It works entirely in ordinary HTTP headers, so an app on a phone can use it with the same HTTP library it already uses for every other request.

The outline is short. The app creates a key pair before it asks for tokens. With its token request it sends a small signed JWT, called a DPoP proof, that contains its public key, and the authorization server records which public key the tokens belong to. From then on, every request that uses the token must arrive with a fresh proof signed by the matching private key. It is the proof of possession from Secrets and key pairs, repeated on every call.

The private key never travels. It does not go to the authorization server or the photo API, and it does not appear in any token. Only the public key is sent, inside each proof, and a public key is no help to anyone who wants to sign.

Giving the app a key pair

All domains, codes, and tokens in these examples are fictional. When Ava connects her photo account in the app, the app generates an elliptic curve key pair on the P-256 curve, for the ES256 signature algorithm that Choosing and enforcing algorithms described. It keeps the private key in the phone's protected key storage, the Keychain on Apple devices or the Android Keystore, and marks it non-exportable where the platform allows. As Storing and using keys explained, the app can then ask the platform for signatures but cannot read the key out, and neither can anything that copies the app's files.

The public half, written as a JSON Web Key, looks like this:

{
  "kty": "EC",
  "crv": "P-256",
  "x": "DboN9G_lcWgZ3rxckKu35JwH2OYBLWJgxcT_-KEXK8Y",
  "y": "rj69LkdPmdnAbPoBq6mpcpbJPWLEQ6Qs2SaMMyKWBSk"
}

This public key was generated for these examples and its private half was discarded, so nobody can sign with it.

Nothing about this key is registered in advance. A key registered for private_key_jwt, as in Secrets and signed assertions, is known to the authorization server before any request arrives. A DPoP key can be created by any installation at any moment. That is why DPoP suits a public client like the phone app: there is no secret to hide in the app package, because each copy of the app makes its own key on its own phone.

It also means DPoP is not client authentication. Anyone can generate a key pair and send a proof, including someone who writes their own app that imitates the printer's. A valid proof shows that a request comes from the same key holder the token was issued to. It does not show that the holder is the genuine printer app, and photo-printer-app remains a public client.

Asking for a bound token

After Ava approves the connection, the app exchanges its authorization code as Exchanging a code for tokens showed, with its PKCE verifier and no client secret, and with one addition: a DPoP header carrying a proof. The proof is shortened here for display:

POST /token HTTP/1.1
Host: auth.photos.example
Content-Type: application/x-www-form-urlencoded
DPoP: eyJ0eXAiOiJkcG9wK2p3dCIsImFsZyI6IkVTMjU2IiwiandrIjp7Imt0eSI6IkVDIiwiY3J2IjoiUC0yNTYi...

grant_type=authorization_code
&code=demo-app-code-1
&redirect_uri=https%3A%2F%2Fapp.printer.example%2Foauth%2Fcallback
&code_verifier=demo_app_verifier_created_for_one_attempt_only_2026
&client_id=photo-printer-app

The authorization server checks the proof, then binds the tokens it issues to the public key inside it:

HTTP/1.1 200 OK
Content-Type: application/json
Cache-Control: no-store

{
  "access_token": "demo-app-access-token-1",
  "token_type": "DPoP",
  "expires_in": 600,
  "refresh_token": "demo-app-refresh-token-1",
  "scope": "photos.read"
}

The token_type is the signal. DPoP tells the app that the access token is bound to its key and must travel with a proof on every request. If the server answered Bearer instead, it would have chosen not to bind the access token, which would then be an ordinary bearer token. The specification lets a client that expected a bound token discard such a response, and a client that relies on the binding for its security should do exactly that rather than carry on unprotected.

Because the app is a public client, the refresh token is bound to the same key. A confidential client proves who it is every time it refreshes, but the phone app has nothing to prove that with, so the key does the job: a refresh token copied out of the phone is as useless without the key as the access token is.

Recording the key in the token

The photo API needs to know which key the token belongs to without asking the app, and the authorization server tells it inside the token. Like demo-access-token-7 in Token formats and validation, demo-app-access-token-1 is a readable stand-in for an encoded JWT. Decoded, its claims are:

{
  "iss": "https://auth.photos.example",
  "sub": "user-2048",
  "aud": "https://api.photos.example",
  "client_id": "photo-printer-app",
  "scope": "photos.read",
  "iat": 1790845200,
  "exp": 1790845800,
  "jti": "demo-app-token-id-1",
  "cnf": {
    "jkt": "BVohHgHi0D9O5iBFRpVSFAukBjzgVbIRUjYuTsfJER8"
  }
}

The cnf claim is the confirmation claim that Token theft and replay mentioned: it names the key a presenter of this token must prove it holds. Its jkt member is the JWK thumbprint of the app's public key, a SHA-256 hash of a fixed, canonical form of the key defined in RFC 7638. A thumbprint is short, the same size for every key, and changes completely if any part of the key changes. Creating a DPoP proof computes this one step by step.

When the access token is opaque rather than a JWT, the photo API learns the same value from the authorization server instead. An introspection response for a bound token, the call Token introspection described, carries the same cnf member with the same thumbprint.

Put the pieces together and a copied token looks very different. Suppose the app's crash reporter writes demo-app-access-token-1 into a log. Whoever reads the log can send the token, but the photo API also wants a proof signed by a key whose thumbprint is BVohHgHi0D9O5iBFRpVSFAukBjzgVbIRUjYuTsfJER8. They can make a proof with a key of their own, and its signature will verify, but its thumbprint will not match, so the photo API refuses the request. Sending the copy as a plain bearer token, with no proof at all, fails too at an API that knows the token is bound.

Bearer token copied from a log

Token
Valid
Sent with
No proof
Key named
None

Accepted for anyone

DPoP-bound copy, a key of their own

Token
Valid
Sent with
Proof that verifies
Key named
Not cnf.jkt

Refused

Ava's phone app

Token
Valid
Sent with
Proof from the phone key
Key named
cnf.jkt

Accepted

It does not show that the holder is the genuine printer app.

The same token copied from a log works as a bearer token, but a DPoP-bound copy fails because no one outside Ava's phone can make a proof whose key matches cnf.jkt.

The token has become one half of a credential, and the other half stays in the phone's key storage.

Check your understanding

Try these questions before moving on. If an answer isn't right, use the feedback and try again.

A crash log captured the DPoP-bound access token the printer's phone app holds for Ava. Why can't the person reading the log use it at the photo API? 1 of 3

Choose one answer.

Someone writes their own app, generates a key pair, and sends valid DPoP proofs to the photo service. What has DPoP established about them? 2 of 3

Choose one answer.

The phone app sends Ava's code exchange with a DPoP proof, and the response says "token_type": "Bearer". The app relies on binding. What should it do? 3 of 3

Choose one answer.

Try it in the Lab

We value your privacy

We use cookies and similar technologies to enhance your browsing experience, and analytics to understand our traffic. By clicking "Allow all", you consent to optional analytics. Cookie Policy

Learn identity