Context
azure-identity introduced its new multi-tenant authentication API get_token(tenant_id=...):
Meanwhile, before this is implemented, Azure CLI developed its own multi-tenant authentication implementation using CredentialAdaptor.get_auxiliary_tokens (#19853):
|
# Track 2 currently lacks the ability to take external credentials. |
|
# https://github.com/Azure/azure-sdk-for-python/issues/8313 |
|
# As a temporary workaround, manually add external tokens to 'x-ms-authorization-auxiliary' header. |
|
# https://docs.microsoft.com/en-us/azure/azure-resource-manager/management/authenticate-multi-tenant |
|
if hasattr(cred, "get_auxiliary_tokens"): |
|
aux_tokens = cred.get_auxiliary_tokens(*scopes) |
|
if aux_tokens: |
|
# Hard-code scheme to 'Bearer' as _BearerTokenCredentialPolicyBase._update_headers does. |
|
client_kwargs['headers']['x-ms-authorization-auxiliary'] = \ |
|
', '.join("Bearer {}".format(token.token) for token in aux_tokens) |
This makes CredentialAdaptor.get_token incompatible with azure-identity's InteractiveCredential.get_token which takes tenant_id and resolves it at
https://github.com/Azure/azure-sdk-for-python/blob/01d0b99e53a1995b39e59649bf3d550dc5408875/sdk/identity/azure-identity/azure/identity/_internal/msal_credentials.py#L62
def _get_app(self, **kwargs):
# type: (**Any) -> msal.ClientApplication
tenant_id = resolve_tenant(self._tenant_id, **kwargs)
TODO
CredentialAdaptor.get_token should be able to take tenant_id.
References
Context
azure-identityintroduced its new multi-tenant authentication APIget_token(tenant_id=...):Meanwhile, before this is implemented, Azure CLI developed its own multi-tenant authentication implementation using
CredentialAdaptor.get_auxiliary_tokens(#19853):azure-cli/src/azure-cli-core/azure/cli/core/commands/client_factory.py
Lines 180 to 189 in 110f7b4
This makes
CredentialAdaptor.get_tokenincompatible withazure-identity'sInteractiveCredential.get_tokenwhich takestenant_idand resolves it athttps://github.com/Azure/azure-sdk-for-python/blob/01d0b99e53a1995b39e59649bf3d550dc5408875/sdk/identity/azure-identity/azure/identity/_internal/msal_credentials.py#L62
TODO
CredentialAdaptor.get_tokenshould be able to taketenant_id.References
azure-keyvault-keys==4.5.0b4#20880az keyvault key createfails: Session.request() got an unexpected keyword argument 'tenant_id' #20856