Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces a dual-client architecture in DefaultClient to prevent OkHttp's automatic retry mechanism from causing DPoP (Demonstrating Proof-of-Possession) replay protection errors. DPoP proofs contain unique, non-replayable tokens, and when OkHttp retries a request with the same proof, the server returns a "proof already used" error.
Changes:
- Added
nonRetryableOkHttpClientproperty that shares configuration with the main client but hasretryOnConnectionFailureset to false - Implemented
shouldUseNonRetryableClient()method to detect DPoP requests by checking for the DPoP header - Modified
prepareCall()to select the appropriate client based on the presence of the DPoP header
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| auth0/src/main/java/com/auth0/android/request/DefaultClient.kt | Adds dual-client architecture with non-retryable client for DPoP requests, includes client selection logic based on DPoP header presence |
| auth0/src/test/java/com/auth0/android/request/DefaultClientTest.kt | Adds 2 configuration tests verifying both clients exist with correct settings and share the same configuration |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| /** | ||
| * Determines if the request should use the non-retryable OkHttpClient. | ||
| * Returns true for: | ||
| * 1. Requests with DPoP header |
There was a problem hiding this comment.
do we have other conditions too for which non retryable client must be used?
There was a problem hiding this comment.
Currently Dpop scenario is where this is causing major error. We can update these cases on need to basis like refresh token exchange etc
Description
This PR introduces a dual-client architecture in
DefaultClientto prevent OkHttp from automatically retrying network requests that use DPoP (Demonstrating Proof-of-Possession). DPoP proofs contain unique, non-replayable tokens (jticlaims and timestamps), and OkHttp's automatic retry mechanism can cause "proof already used" errors when the same proof is sent twice.Changes
Core Implementation (
DefaultClient.kt)nonRetryableOkHttpClientproperty withretryOnConnectionFailure = falseTesting
All tests pass successfully