Creating a DPoP proof
A DPoP-bound tokenA piece of data issued by a trusted service that a client presents as a credential, for example to call an API or to report a sign-in. Some tokens carry readable claims; others are random strings that only the issuer can interpret. never travels alone. Each request that uses it carries a short-lived 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. beside it, signed with the client's 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., that describes that one request. This lesson reads the two proofs the printer's phone app makes while it connects Ava's account and opens her first album, and computes the two hashes they depend on.
The proof at the token endpoint
In Binding a token to a key, the phone app sent Ava's code exchange with a DPoP header and received tokens bound to its key. The header held a proof, which is a JWT like any other: a header, a set of claims and a 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., as Inside a JWT described. All domains, codes, and tokens in these examples are fictional. Decoded, that proof reads:
Header:
{
"typ": "dpop+jwt",
"alg": "ES256",
"jwk": {
"kty": "EC",
"crv": "P-256",
"x": "DboN9G_lcWgZ3rxckKu35JwH2OYBLWJgxcT_-KEXK8Y",
"y": "rj69LkdPmdnAbPoBq6mpcpbJPWLEQ6Qs2SaMMyKWBSk"
}
}
Claims:
{
"jti": "demo-proof-1",
"htm": "POST",
"htu": "https://auth.photos.example/token",
"iat": 1790845200
}The header does more work than usual. typ is dpop+jwt, an explicit type that keeps a proof from being mistaken for any other kind of JWT, and any other JWT from being accepted as a proof. alg names an asymmetric signature algorithm. It can never be none, and never a shared-key algorithm such as HMAC, where whoever checks the signature holds the same key as whoever made it: the point is that only the app can sign. jwk carries the app's 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., the one from Binding a token to a key, and must never include private key members such as d.
The claims describe the request:
jtiis a unique identifier for this proof. A real one is random, for example at least 96 bits of random data. The readable value here stands in for it.htmis the HTTPThe Hypertext Transfer Protocol, the rules browsers, apps, and servers use to send requests and responses on the web. method of the request, herePOST.htuis the address the request is sent to, without any query string or fragment.iatis when the proof was created, in Unix seconds: 1790845200 is 09:00:00 UTC on 1 October 2026.
The app encodes the header and claims, asks the phone's key storage to sign them with the private key, and puts the result in the DPoP header of the token request. The value begins with the encoded header, eyJ0eXAiOiJkcG9wK2p3dCIsImFsZyI6IkVTMjU2Iiwiandr..., and ends with the signature.
Notice what the proof leaves out. There is no client secretA shared secret that a confidential client uses to prove itself to the authorization server, much like a password for an application. It belongs on a backend, never in code sent to browsers or phones., no authorization codeA short-lived, single-use value that the authorization server sends back to a client through the browser. The client swaps it for tokens in a direct request to the authorization server; APIs never accept it. and nothing from the request body. A proof signs only the method, the address, the time and a unique identifier, which keeps it simple to build and check, and TLSTransport Layer Security, the protection behind HTTPS. It encrypts traffic between two connected systems, detects changes on the way, and uses certificates so the client can confirm which server it reached. protects the rest of the request as it always does.
The proof at the photo API
Twelve seconds later, the app asks for the photos in Ava's album 42. The request carries the 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. in the Authorization header, with the DPoP scheme in place of Bearer, and a new proof:
GET /albums/42/photos HTTP/1.1
Host: api.photos.example
Authorization: DPoP demo-app-access-token-1
DPoP: eyJ0eXAiOiJkcG9wK2p3dCIsImFsZyI6IkVTMjU2IiwiandrIjp7Imt0eSI6IkVDIiwiY3J2IjoiUC0yNTYi...The proof's header is identical, because the key is the same. Its claims are new:
{
"jti": "demo-proof-2",
"htm": "GET",
"htu": "https://api.photos.example/albums/42/photos",
"iat": 1790845212,
"ath": "xcbjgyKf_F3-foHYAOd_VdSpNEB0ThBmPo1xXGoYihA"
}Every claim has changed. The identifier is new, the method and address are those of this request, and the time is 09:00:12. Had the app asked for https://api.photos.example/photos?page=2, the htu would be https://api.photos.example/photos, because the query string is left out.
The new claim, ath, is a hashTurning data into a short, fixed-size value called a hash, in a way that cannot be reversed and where changing one character changes the result completely. Services store password hashes instead of passwords, and signatures are made over a hash. of the access token sent with the proof, and it is required whenever a proof accompanies an access token. It ties this proof to this token. Without it, a proof made for one request could be paired with a different token the same app holds, for example one issued for a second photo account on the same phone. With it, a proof is useless without its token, and the token is useless without a proof that names it.
Computing the hashes
Two values in these examples are hashes, and both are easy to get subtly wrong. Both use SHA-256 and the Base64urlA way of encoding data as ordinary text characters so it can travel safely in headers, URLs, and JSON. Anyone can decode it, so it hides nothing; Base64url is a variant safe for URLs, used in JWTs. encoding without padding from Encoding and hashing.
The thumbprint in the token's cnf.jkt is computed from the public key alone. For an elliptic curve key, take only the four required members, crv, kty, x and y, write them as JSON in that alphabetical order with no spaces or line breaks, hash those bytes, and encode the result:
Canonical JSON:
{"crv":"P-256","kty":"EC","x":"DboN9G_lcWgZ3rxckKu35JwH2OYBLWJgxcT_-KEXK8Y","y":"rj69LkdPmdnAbPoBq6mpcpbJPWLEQ6Qs2SaMMyKWBSk"}
jkt = BASE64URL(SHA-256(canonical JSON))
= BVohHgHi0D9O5iBFRpVSFAukBjzgVbIRUjYuTsfJER8The fixed form is what makes the thumbprint useful. The authorization server computes it when it binds the token, and the photo API computes it again from the key in each proof, so both must produce exactly the same bytes from the same key.
The ath claim is computed from the access token: the SHA-256 hash of the exact token string, encoded the same way. Here that string is demo-app-access-token-1. For a real JWT access token it is the whole encoded token, exactly as the app received it.
In TypeScript on Node.js, both take a few lines. sha256url hashes a string's UTF-8 bytes and encodes the digest as Base64url; the thumbprint line builds the canonical JSON from the key's four members in order, and the last line hashes the token:
import { createHash } from 'node:crypto';
const sha256url = (text: string) =>
createHash('sha256').update(text, 'utf8').digest('base64url');
// jwk is the app's public key, as shown above
// JWK thumbprint: required members only, in this order, no whitespace
const jkt = sha256url(JSON.stringify({ crv: jwk.crv, kty: jwk.kty, x: jwk.x, y: jwk.y }));
// Access token hash for the ath claim
const ath = sha256url('demo-app-access-token-1');
// ath === 'xcbjgyKf_F3-foHYAOd_VdSpNEB0ThBmPo1xXGoYihA'Node's base64url encoding already leaves out the padding. The common mistakes are all small: adding kid or alg to the thumbprint input, letting a JSON library reorder or indent the members, hashing the whole Authorization header value instead of the token, or encoding with ordinary Base64, whose +, / and = characters make a different string. Each one produces a value that looks plausible and never matches.
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
- Build DPoP proofs for the token endpoint and the photo APIMake and read lab-printer-app's proofs for a code exchange and an album request, see htm and ath refuse a proof made for another request, and reproduce the lesson's thumbprint and ath by hand.