Generate Proof
Generate proof for DPoP token exchange.
When to use: Use this when building a non-browser client or testing DPoP flows without a real frontend.
Client Flow Diagram

5-Line Core
Essential code to generate proof for DPoP token.
Step-by-Step
Proof Structure Table
htm
HTTP method
htu
HTTP URL
jti
Replay prevention
ath
Access token hash
iat
Freshness
Common Pitfalls
Generating a new key for every request
DPoP keys are misunderstood as per-request instead of per-client
Generate the key once and persist it; reuse the same key for token requests and API calls
Using different keys for token request and API access
Token binding (cnf.jkt) ties the token to a specific public key
Always use the same private key that was used when requesting the access token
Reusing the same DPoP proof
DPoP proofs are one-time use and include jti
Generate a new proof for every HTTP request
Missing ath claim for resource requests
ath is optional for token requests but required for resource access
Include the access token when calling create_proof() for API requests
Incorrect HTTP method or URL in proof
Proofs bind to exact htm and htu values
Ensure the method and URL exactly match the outgoing HTTP request
Forgetting to handle nonce challenges
Some servers require nonce-based replay protection
On 401 + DPoP-Nonce, regenerate the proof including the nonce and retry
Treating DPoP as a browser-only feature
DPoP is often assumed to be frontend-only
Non-browser clients must explicitly manage key storage and proof generation
Production Notes
This proof-generation flow is for demonstration purposes only. In production, DPoP private keys must be generated, stored, and used inside a secure browser or mobile keystore.
Persisting keys to disk and accessing private key material directly—as shown in this example—is not appropriate for real clients and is used here solely to make the DPoP flow explicit.
Guidelines for Production Deployments
Enable DPoP Only on HTTPS Endpoints Use HTTPS to transmit DPoP proofs and tokens securely via HTTP headers, preventing interception and replay attacks.
Decide on DPoP Requirement During migration, support both bearer and DPoP tokens. For production, set:
This setting helps fully prevent bearer-token replay attacks.
Enable Nonce Protection for High-Security APIs Use nonce enforcement for an extra replay protection layer, especially for:
Financial operations
Privileged admin APIs
Internet-facing services
Separate DPoP from Authorization DPoP ensures token possession but not permission. Continuously enforce:
Role checks
Organization membership
Resource-level authorization
Monitor and Log DPoP Validation Failures Look out for potential issues such as:
Client misconfiguration
Replay attempts
Token theft attempts Ensure these events are observable in production logs and metrics.
Thoroughly Test with Real Clients Beyond Python scripts for testing and CI, validate production readiness using:
Browser-based clients
Mobile apps
Real HTTP stacks with retries and concurrency
Found an issue on this page? Report it on our feedback form.
Last updated
Was this helpful?