Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always run MsalSilentBearerTokenProvider to provide cached and refreshed tokens #384

Merged
merged 1 commit into from
Apr 14, 2023

Conversation

JohnSchmeichel
Copy link
Member

@JohnSchmeichel JohnSchmeichel commented Apr 13, 2023

Previously in ADAL AdalCacheBearerTokenProvider would be skipped if IsRetry was true, but rely on WindowsIntegratedAuthBearerTokenProvider to provide a cached token. In the MSAL variants, MsalSilentBearerTokenProvider would also be skipped if IsRetry was true, but in this case MsalWindowsIntegratedAuthBearerTokenProvider does not provide cached tokens, leading to a prompt.

In MSAL the AcquireTokenSilent calls obtain cached or refreshed tokens for both brokered and non-broker cases, and we should rely on the fact that this will always return a valid token. So MsalSilentBearerTokenProvider should always be run to provide cached tokens.

The context here is that we've seen some bad cases where NuGet clients are dropping or invalidating access tokens, getting Unauthorized (401) responses from external endpoints, then calling back into the credential provider for new tokens. These cases require both the token cache and/or silent authentication to be enabled otherwise users get constant prompts during package restore.

@JohnSchmeichel JohnSchmeichel merged commit 6d40d5b into master Apr 14, 2023
2 checks passed
@JohnSchmeichel JohnSchmeichel deleted the johsch/msal-silent branch April 24, 2023 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants