Remove acquire_token_silent(..., account=None) usage in a backward-compatible way #577
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|.