Binding a token to a key
A bearer tokenA token that works for whoever presents it: the API checks that the token is genuine and current, not who is holding it. That is why bearer tokens must be kept from being copied. works for anyone who holds a copy. Demonstrating Proof of Possession, or DPoP, binds a token to a key pairA private key and a public key generated together and mathematically linked. The private key creates signatures and the public key checks them, but the private key cannot practically be worked out from the public one. the client generated, so the token is accepted only beside a fresh proof signed with the private keyThe half of a key pair that its owner keeps to themselves and uses to create signatures or decrypt data. Anyone who obtains it can act as its owner.. 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 tokenA token that a client presents to an API to use access it has been granted, usually limited in what it allows and how long it lasts. It authorizes API calls; it does not tell the client who signed in. for the photo APIAn application programming interface: a defined way for software to interact with a service. A web API offers endpoints where other programs send HTTP requests. and a refresh tokenA longer-lived credential that a client sends to the authorization server, never to an API, to get new access tokens without asking the person again. 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 HTTPThe Hypertext Transfer Protocol, the rules browsers, apps, and servers use to send requests and responses on the web. 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 JWTA JSON Web Token: a compact token made of Base64url-encoded parts that carries claims and is usually signed. Anyone holding it can decode and read the claims, so the signature shows who issued it but hides nothing., called a DPoP proof, that contains its public keyThe half of a key pair that can be shared freely. It checks signatures made with the matching private key and can encrypt data that only that private key can decrypt., and the authorization serverIn OAuth, the service that handles a person's sign-in and approval and decides which tokens to issue to a client. It may belong to the same company as the API, but its job is separate. 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 authorizationDeciding whether a requested action is permitted, such as whether a signed-in account may delete a particular photo. Authentication says which account is asking; authorization decides what it can do. 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 signatureA value made with a private key that lets anyone holding the matching public key check that a message came from the key's holder and has not been changed. It proves origin and integrity; it does not hide the message. 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-appThe 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 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.
Try it in the Lab
- Bind the phone app's tokens to a key it generatedAct as lab-printer-app: generate a key and its thumbprint, redeem Ava's code with a DPoP proof, find the key in cnf.jkt, and see the bound token refused without its key.