-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add interactive_browser_client_id #20591
Changes from 7 commits
aabed35
1bad811
aaf7bff
f388d7b
85c05a3
3722f87
6acfbc7
8377f88
fb8cef8
6d0e1d1
c37f200
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
# ------------------------------------ | ||
import logging | ||
import os | ||
import six | ||
|
||
from .._constants import EnvironmentVariables | ||
from .._internal import get_default_authority, normalize_authority | ||
|
@@ -70,6 +71,8 @@ class DefaultAzureCredential(ChainedTokenCredential): | |
AZURE_TENANT_ID, if any. If unspecified, users will authenticate in their home tenants. | ||
:keyword str managed_identity_client_id: The client ID of a user-assigned managed identity. Defaults to the value | ||
of the environment variable AZURE_CLIENT_ID, if any. If not specified, a system-assigned identity will be used. | ||
:keyword str interactive_browser_client_id: The client ID to be used in interactive browser credential. If not | ||
specified, users will authenticate to an Azure development application. | ||
:keyword str shared_cache_username: Preferred username for :class:`~azure.identity.SharedTokenCacheCredential`. | ||
Defaults to the value of environment variable AZURE_USERNAME, if any. | ||
:keyword str shared_cache_tenant_id: Preferred tenant for :class:`~azure.identity.SharedTokenCacheCredential`. | ||
|
@@ -102,6 +105,7 @@ def __init__(self, **kwargs): | |
managed_identity_client_id = kwargs.pop( | ||
"managed_identity_client_id", os.environ.get(EnvironmentVariables.AZURE_CLIENT_ID) | ||
) | ||
interactive_browser_client_id = kwargs.pop("interactive_browser_client_id", None) | ||
|
||
shared_cache_username = kwargs.pop("shared_cache_username", os.environ.get(EnvironmentVariables.AZURE_USERNAME)) | ||
shared_cache_tenant_id = kwargs.pop( | ||
|
@@ -137,7 +141,15 @@ def __init__(self, **kwargs): | |
if not exclude_powershell_credential: | ||
credentials.append(AzurePowerShellCredential(**kwargs)) | ||
if not exclude_interactive_browser_credential: | ||
credentials.append(InteractiveBrowserCredential(tenant_id=interactive_browser_tenant_id, **kwargs)) | ||
if interactive_browser_client_id: | ||
if not isinstance(interactive_browser_client_id, six.string_types): | ||
raise ValueError('"interactive_browser_client_id" must be a string') | ||
credentials.append(InteractiveBrowserCredential( | ||
tenant_id=interactive_browser_tenant_id, | ||
client_id=interactive_browser_client_id, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. InteractiveBrowserCredential expects this argument to be set only with a valid client ID (i.e. a string). So, we should pass a value here only when interactive_browser_client_id has a string value. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see we do similar validation for other client ids. Should we keep consistent with others? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
**kwargs)) | ||
xiangyan99 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
else: | ||
credentials.append(InteractiveBrowserCredential(tenant_id=interactive_browser_tenant_id, **kwargs)) | ||
|
||
super(DefaultAzureCredential, self).__init__(*credentials) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is unused now