Add a callback for background token refresh outcomes#6099
Open
neha-bhargava wants to merge 1 commit into
Open
Conversation
Proactive (background) refresh is fire-and-forget, so callers can't see whether it succeeded, how long it took, or why it failed. This adds an opt-in callback (confidential client + managed identity) that hands back the AuthenticationResult on success or the exception on failure - with the HTTP duration and cache-refresh reason attached, so telemetry layers can report on this path. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Proactive (background) token refresh is fire-and-forget: once the caller has a cached token, MSAL refreshes it on a background thread and the outcome is invisible from the outside. This adds an opt-in callback so that path can be observed - e.g. for telemetry parity during the SEAL -> MSAL migration.
OnBackgroundTokenRefreshCompleted(Func<ExecutionResult, Task>)on the confidential client and managed identity builders (experimental).AuthenticationResult; on failure it gets the exception, with the HTTP duration and cache-refresh reason on itsAuthenticationResultMetadata.RunAsync, so the failure metadata is filled in fromapiEventinProcessFetchInBackground.Stacked on #6096 (which adds
AuthenticationResultMetadatatoMsalException) and targets that branch, so please review it after #6096. Work item 3682729.