Skip to content

Commit 102d717

Browse files
authored
make tenant_id kw only (#25555)
1 parent bd98125 commit 102d717

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

sdk/identity/azure-identity/azure/identity/_credentials/azure_cli.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,10 @@ class AzureCliCredential(object):
3535
"""Authenticates by requesting a token from the Azure CLI.
3636
3737
This requires previously logging in to Azure via "az login", and will use the CLI's currently logged in identity.
38+
39+
:keyword str tenant_id: optional tenant to include in the token request.
3840
"""
39-
def __init__(self, tenant_id: str = ""):
41+
def __init__(self, *, tenant_id: str = ""):
4042
object.__init__(self)
4143

4244
self.tenant_id = tenant_id
@@ -71,7 +73,7 @@ def get_token(self, *scopes, **kwargs): # pylint: disable=no-self-use
7173

7274
resource = _scopes_to_resource(*scopes)
7375
command = COMMAND_LINE.format(resource)
74-
tenant = resolve_tenant(default_tenant= self.tenant_id, **kwargs)
76+
tenant = resolve_tenant(default_tenant=self.tenant_id, **kwargs)
7577

7678
if tenant:
7779
command += " --tenant " + tenant

sdk/identity/azure-identity/azure/identity/aio/_credentials/azure_cli.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@ class AzureCliCredential(AsyncContextManager):
3131
"""Authenticates by requesting a token from the Azure CLI.
3232
3333
This requires previously logging in to Azure via "az login", and will use the CLI's currently logged in identity.
34+
35+
:keyword str tenant_id: optional tenant to include in the token request.
3436
"""
35-
def __init__(self, tenant_id: str = ""):
37+
def __init__(self, *, tenant_id: str = ""):
3638
AsyncContextManager.__init__(self)
3739

3840
self.tenant_id = tenant_id
@@ -59,7 +61,7 @@ async def get_token(self, *scopes: str, **kwargs: "Any") -> "AccessToken":
5961

6062
resource = _scopes_to_resource(*scopes)
6163
command = COMMAND_LINE.format(resource)
62-
tenant = resolve_tenant(default_tenant= self.tenant_id, **kwargs)
64+
tenant = resolve_tenant(default_tenant=self.tenant_id, **kwargs)
6365

6466
if tenant:
6567
command += " --tenant " + tenant

0 commit comments

Comments
 (0)