You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit e5b1321
Browse filesBrowse the repository at this point in the historyBrowse files
Fix ClientOAuthProvider cold-start refresh when client ID isn't persisted
On a cold start where a durable ITokenCache returns a persisted refresh
token but no client ID has been assigned yet (DCR/CIMD clients),
GetAccessTokenCoreAsync attempted a token refresh before assigning a
client ID, causing CreateTokenRequest -> GetClientIdOrThrow() to throw
'Client ID is not available'.
Persist the client registration (client ID, secret, token endpoint auth
method) alongside the tokens so a single durable ITokenCache can use the
refresh token after a restart, and restore it on a cold start before the
refresh attempt. Also guard the refresh block with a client-ID check so
the flow falls through to client-ID assignment and the authorization-code
flow instead of throwing when no credentials are available.
The restore and persistence run inside the provider's _tokenAcquisitionLock
(added in #1708), so the shared credential fields are written under the
same lock that serializes the rest of the auth state; no new races are
introduced.
Fixes#1658
Co-authored-by: Copilot App <[email protected]>
privatestringGetClientIdOrThrow()=>_clientId??thrownewInvalidOperationException("Client ID is not available. This may indicate an issue with dynamic client registration.");
1261
1277
1278
+
/// <summary>
1279
+
/// Restores the client registration persisted alongside cached tokens when this provider has not been
1280
+
/// assigned a client ID yet. This allows a durable <see cref="ITokenCache"/> to use a refresh token that
1281
+
/// survived a process restart without re-running dynamic client registration. An explicitly configured
1282
+
/// client ID always takes precedence, so nothing is restored when one is already available.
1283
+
/// </summary>
1284
+
/// <remarks>
1285
+
/// Callers must hold <c>_tokenAcquisitionLock</c>: this writes the shared <c>_clientId</c>,
1286
+
/// <c>_clientSecret</c>, and <c>_tokenEndpointAuthMethod</c> fields, which the lock serializes.
0 commit comments