-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
{Core} Decouple MSAL credentials from SDK get_token
protocol
#29955
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_token
protocol. Make MSAL credentials implementacquire_token
and return MSAL tokendict
.CredentialAdaptor
CredentialAdaptor
was initially introduced as an adaptor for both Track 1 and Track 2 SDKs by implementing bothsigned_session
andget_token
protocol. As Track 1 SDK andsigned_session
support has been dropped (#29631),CredentialAdaptor
is now repurposed as an adaptor between Track 2 SDK and MSAL credentials. So we moveAccessToken
's building logic toCredentialAdaptor
and makeCredentialAdaptor
implementget_token()
.In the future,
CredentialAdaptor
will be changed to implement the newget_token_info()
protocol (Azure/azure-sdk-for-python#36565, Azure/azure-sdk-for-python#36882).