Skip to content

Commit 0f28626

Browse files
committed
refactor-args
1 parent 46da4e9 commit 0f28626

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

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

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,8 @@ def get_login_credentials(self, resource=None, client_id=None, subscription_id=N
413413
credential = self._create_credential(account, client_id=client_id)
414414
external_credentials = []
415415
for external_tenant in external_tenants:
416-
external_credentials.append(self._create_credential(account, external_tenant, client_id=client_id))
416+
external_credentials.append(self._create_credential(account, tenant_id=external_tenant,
417+
client_id=client_id))
417418
from azure.cli.core.auth.credential_adaptor import CredentialAdaptor
418419
cred = CredentialAdaptor(credential,
419420
auxiliary_credentials=external_credentials,
@@ -460,7 +461,7 @@ def get_raw_token(self, resource=None, scopes=None, subscription=None, tenant=No
460461
scopes_to_resource(scopes))
461462

462463
else:
463-
cred = self._create_credential(account, tenant)
464+
cred = self._create_credential(account, tenant_id=tenant)
464465

465466
sdk_token = cred.get_token(*scopes)
466467
# Convert epoch int 'expires_on' to datetime string 'expiresOn' for backward compatibility
@@ -665,7 +666,7 @@ def _create_credential(self, account, tenant_id=None, client_id=None):
665666
"""
666667
user_type = account[_USER_ENTITY][_USER_TYPE]
667668
username_or_sp_id = account[_USER_ENTITY][_USER_NAME]
668-
tenant_id = tenant_id if tenant_id else account[_TENANT_ID]
669+
tenant_id = tenant_id or account[_TENANT_ID]
669670
identity = _create_identity_instance(self.cli_ctx, self._authority, tenant_id=tenant_id, client_id=client_id)
670671

671672
# User
@@ -694,7 +695,7 @@ def refresh_accounts(self):
694695
tenant = s[_TENANT_ID]
695696
subscriptions = []
696697
try:
697-
identity_credential = self._create_credential(s, tenant)
698+
identity_credential = self._create_credential(s, tenant_id=tenant)
698699
if is_service_principal:
699700
subscriptions = subscription_finder.find_using_specific_tenant(tenant, identity_credential)
700701
else:
@@ -938,7 +939,7 @@ def _transform_subscription_for_multiapi(s, s_dict):
938939
s_dict[_MANAGED_BY_TENANTS] = [{_TENANT_ID: t.tenant_id} for t in s.managed_by_tenants]
939940

940941

941-
def _create_identity_instance(cli_ctx, *args, **kwargs):
942+
def _create_identity_instance(cli_ctx, authority, tenant_id=None, client_id=None):
942943
"""Lazily import and create Identity instance to avoid unnecessary imports."""
943944
from .auth.identity import Identity
944945
from .util import should_encrypt_token_cache
@@ -955,9 +956,11 @@ def _create_identity_instance(cli_ctx, *args, **kwargs):
955956
# PREVIEW: In Azure Stack environment, use core.instance_discovery=false to disable MSAL's instance discovery.
956957
instance_discovery = cli_ctx.config.getboolean('core', 'instance_discovery', True)
957958

958-
return Identity(*args, encrypt=encrypt, use_msal_http_cache=use_msal_http_cache,
959+
return Identity(authority, tenant_id=tenant_id, client_id=client_id,
960+
encrypt=encrypt,
961+
use_msal_http_cache=use_msal_http_cache,
959962
enable_broker_on_windows=enable_broker_on_windows,
960-
instance_discovery=instance_discovery, **kwargs)
963+
instance_discovery=instance_discovery)
961964

962965

963966
def _on_azure_arc_windows():

0 commit comments

Comments
 (0)