@@ -362,12 +362,10 @@ def logout_all(self):
362362 identity .logout_all_users ()
363363 identity .logout_all_service_principal ()
364364
365- def get_login_credentials (self , resource = None , client_id = None , subscription_id = None , aux_subscriptions = None ,
366- aux_tenants = None ):
365+ def get_login_credentials (self , resource = None , subscription_id = None , aux_subscriptions = None , aux_tenants = None ):
367366 """Get a CredentialAdaptor instance to be used with both Track 1 and Track 2 SDKs.
368367
369368 :param resource: The resource ID to acquire an access token. Only provide it for Track 1 SDKs.
370- :param client_id:
371369 :param subscription_id:
372370 :param aux_subscriptions:
373371 :param aux_tenants:
@@ -410,10 +408,10 @@ def get_login_credentials(self, resource=None, client_id=None, subscription_id=N
410408 if sub [_TENANT_ID ] != account [_TENANT_ID ]:
411409 external_tenants .append (sub [_TENANT_ID ])
412410
413- credential = self ._create_credential (account , client_id = client_id )
411+ credential = self ._create_credential (account )
414412 external_credentials = []
415413 for external_tenant in external_tenants :
416- external_credentials .append (self ._create_credential (account , external_tenant , client_id = client_id ))
414+ external_credentials .append (self ._create_credential (account , tenant_id = external_tenant ))
417415 from azure .cli .core .auth .credential_adaptor import CredentialAdaptor
418416 cred = CredentialAdaptor (credential ,
419417 auxiliary_credentials = external_credentials ,
@@ -460,7 +458,7 @@ def get_raw_token(self, resource=None, scopes=None, subscription=None, tenant=No
460458 scopes_to_resource (scopes ))
461459
462460 else :
463- cred = self ._create_credential (account , tenant )
461+ cred = self ._create_credential (account , tenant_id = tenant )
464462
465463 sdk_token = cred .get_token (* scopes )
466464 # Convert epoch int 'expires_on' to datetime string 'expiresOn' for backward compatibility
@@ -660,12 +658,11 @@ def _create_credential(self, account, tenant_id=None, client_id=None):
660658
661659 :param account:
662660 :param tenant_id: If not None, override tenantId from 'account'
663- :param client_id:
664661 :return:
665662 """
666663 user_type = account [_USER_ENTITY ][_USER_TYPE ]
667664 username_or_sp_id = account [_USER_ENTITY ][_USER_NAME ]
668- tenant_id = tenant_id if tenant_id else account [_TENANT_ID ]
665+ tenant_id = tenant_id or account [_TENANT_ID ]
669666 identity = _create_identity_instance (self .cli_ctx , self ._authority , tenant_id = tenant_id , client_id = client_id )
670667
671668 # User
@@ -694,7 +691,7 @@ def refresh_accounts(self):
694691 tenant = s [_TENANT_ID ]
695692 subscriptions = []
696693 try :
697- identity_credential = self ._create_credential (s , tenant )
694+ identity_credential = self ._create_credential (s , tenant_id = tenant )
698695 if is_service_principal :
699696 subscriptions = subscription_finder .find_using_specific_tenant (tenant , identity_credential )
700697 else :
@@ -938,7 +935,7 @@ def _transform_subscription_for_multiapi(s, s_dict):
938935 s_dict [_MANAGED_BY_TENANTS ] = [{_TENANT_ID : t .tenant_id } for t in s .managed_by_tenants ]
939936
940937
941- def _create_identity_instance (cli_ctx , * args , ** kwargs ):
938+ def _create_identity_instance (cli_ctx , authority , tenant_id = None , client_id = None ):
942939 """Lazily import and create Identity instance to avoid unnecessary imports."""
943940 from .auth .identity import Identity
944941 from .util import should_encrypt_token_cache
@@ -955,9 +952,11 @@ def _create_identity_instance(cli_ctx, *args, **kwargs):
955952 # PREVIEW: In Azure Stack environment, use core.instance_discovery=false to disable MSAL's instance discovery.
956953 instance_discovery = cli_ctx .config .getboolean ('core' , 'instance_discovery' , True )
957954
958- return Identity (* args , encrypt = encrypt , use_msal_http_cache = use_msal_http_cache ,
955+ return Identity (authority , tenant_id = tenant_id , client_id = client_id ,
956+ encrypt = encrypt ,
957+ use_msal_http_cache = use_msal_http_cache ,
959958 enable_broker_on_windows = enable_broker_on_windows ,
960- instance_discovery = instance_discovery , ** kwargs )
959+ instance_discovery = instance_discovery )
961960
962961
963962def _on_azure_arc_windows ():
0 commit comments