Remove acquire_token_silent(..., account=None) usage in a backward-compatible way#577
Merged
Remove acquire_token_silent(..., account=None) usage in a backward-compatible way#577
Conversation
659eee2 to
93e5643
Compare
05bea64 to
5423c50
Compare
…mpatible way Now acquire_token_for_client()'s cache behavior will have corresponding api id Continue to disallow acquire_token_for_client(..., force_refresh=True)
5423c50 to
2288b77
Compare
This was referenced Jul 22, 2023
Merged
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.
Problem Statement
Historically, MSAL Python's
acquire_token_silent(..., account=...)has two usages:PublicClientApplicationandConfidentialClientApplication.)ConfidentialClientApplication.acquire_token_for_client().)Our existing documentations and samples (for example, this one) always put
#1'sacquire_token_silent(...)call inside theif accountsclause, such that, when the account is None (i.e. the user signed out), the code path shall NOT accidentally attemptacquire_token_silent(..., account=None)otherwise it would potentially return a token for a different entity.However, that relies on the app developer to NOT call
acquire_token_silent(..., account=None)accidentally.Proposal
In this PR,
acquire_token_silent(..., account=None)has been changed to a NO-OP. And the usage#2will be fulfilled byacquire_token_for_client()'s automatically looking up cache, as demonstrated in the updated samples in this PR.The change is therefore backward compatible.
As a byproduct, this PR also modifies the telemetry so that the
acquire_token_for_client(...)will include token refresh reason. For example,4|730,2|, instead of previous4|730,0|.