Skip to content

Commit 1fea7a0

Browse files
committed
Wrap with CredentialAdaptor
1 parent e773611 commit 1fea7a0

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/azure-cli-core/azure/cli/core/_profile.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ def login_with_managed_identity(self, identity_id=None, allow_no_subscriptions=N
219219
identity_type = None
220220
if _msal_managed_identity():
221221
identity_type = MsiAccountTypes.system_assigned
222-
from .auth.msal_authentication import ManagedIdentityCredential
222+
from .auth.msal_credentials import ManagedIdentityCredential
223223
cred = ManagedIdentityCredential()
224224
token = cred.get_token(*self._arm_scope).token
225225
else:
@@ -382,8 +382,11 @@ def get_login_credentials(self, resource=None, client_id=None, subscription_id=N
382382
else:
383383
# managed identity
384384
if _msal_managed_identity():
385-
from .auth.msal_authentication import ManagedIdentityCredential
386-
cred = ManagedIdentityCredential()
385+
from .auth.msal_credentials import ManagedIdentityCredential
386+
from azure.cli.core.auth.credential_adaptor import CredentialAdaptor
387+
mi_cred = ManagedIdentityCredential()
388+
# The mi credential must be wrapped by CredentialAdaptor so that it can work with Track 1 SDKs.
389+
cred = CredentialAdaptor(mi_cred, resource=resource)
387390
else:
388391
cred = MsiAccountTypes.msi_auth_factory(managed_identity_type, managed_identity_id, resource)
389392
return (cred,
@@ -412,7 +415,7 @@ def get_raw_token(self, resource=None, scopes=None, subscription=None, tenant=No
412415
raise CLIError("Tenant shouldn't be specified for managed identity account")
413416
from .auth.util import scopes_to_resource
414417
if _msal_managed_identity():
415-
from .auth.msal_authentication import ManagedIdentityCredential
418+
from .auth.msal_credentials import ManagedIdentityCredential
416419
cred = ManagedIdentityCredential()
417420
else:
418421
cred = MsiAccountTypes.msi_auth_factory(identity_type, identity_id, scopes_to_resource(scopes))

0 commit comments

Comments
 (0)