-
Notifications
You must be signed in to change notification settings - Fork 3.3k
{Core} Decouple MSAL credentials from SDK get_token protocol
#29955
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
Conversation
️✔️AzureCLI-FullTest
|
|
Hi @jiasli, |
️✔️AzureCLI-BreakingChangeTest
|
|
Core |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am considering defining an abstract base classes MsalCredential and let all MSAL credentials inherit from it.
However, Azure Identity only defines TokenCredential as a Protocol
class TokenCredential(Protocol):
"""Protocol for classes able to provide OAuth tokens."""
def get_token(
self,
*scopes: str,
claims: Optional[str] = None,
tenant_id: Optional[str] = None,
enable_cae: bool = False,
**kwargs: Any,
) -> AccessToken:A real credential looks like:
class AzureCliCredential:There is no hard constraints that it must implement get_token method.
get_token protocol
Description
This PR mainly changes the functionality and logic of MSAL credentials and
CredentialAdaptor:MSAL credentials
Decouple MSAL credentials from SDK's
get_tokenprotocol. Make MSAL credentials implementacquire_tokenand return MSAL tokendict.CredentialAdaptorCredentialAdaptorwas initially introduced as an adaptor for both Track 1 and Track 2 SDKs by implementing bothsigned_sessionandget_tokenprotocol. As Track 1 SDK andsigned_sessionsupport has been dropped (#29631),CredentialAdaptoris now repurposed as an adaptor between Track 2 SDK and MSAL credentials. So we moveAccessToken's building logic toCredentialAdaptorand makeCredentialAdaptorimplementget_token().In the future,
CredentialAdaptorwill be changed to implement the newget_token_info()protocol (Azure/azure-sdk-for-python#36565, Azure/azure-sdk-for-python#36882).