Persist DCR client credentials for OAuth session restoration #3418
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Extend OAuth token persistence to also store Dynamic Client Registration (DCR) client credentials. This enables workloads that use DCR (like Datadog and Glean) to restore OAuth sessions across restarts without requiring a new browser-based authentication flow.
This PR builds on #3382 which added refresh token persistence, addressing the remaining issue where DCR servers still required re-authentication because the dynamically registered
client_id(andclient_secretwhere applicable) were lost on restart.Problem
Remote MCP servers that use Dynamic Client Registration (e.g., Datadog, Glean) would lose their OAuth sessions after workload restarts because:
client_idwas not persistedclient_id, the token refresh request fails with "Client ID is required" or similar errorsSolution
Store DCR client credentials in the secret manager alongside refresh tokens:
CachedClientIDRef: Reference to the stored client IDCachedClientSecretRef: Reference to the stored client secret (when issued)For PKCE flows (like Datadog), only the
client_idis persisted since noclient_secretis issued.Changes
CachedClientIDRefandCachedClientSecretReffields toremote.ConfigHasCachedClientCredentials()andClearCachedClientCredentials()helper methodsTokenTypeOAuthClientIDto secrets for secure storageClientIDandClientSecretinOAuthFlowResultfrom discoveryClientCredentialsPersistertype for DCR credential persistenceTesting
HasCachedClientCredentialsandClearCachedClientCredentialsRelated
Closes #3335