Skip to content
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

get_client_from_cli_credentials and sovereign cloud on track2 #18553

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions sdk/core/azure-common/azure/common/credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ class _CliCredentials(object):
:param resource: The resource to use in "msrestazure" mode (ignored otherwise)
"""

_DEFAULT_PREFIX = "/.default"


def __init__(self, cli_profile, resource):
self._profile = cli_profile
self._resource = resource
Expand All @@ -60,13 +59,7 @@ def get_token(self, *scopes, **kwargs): # pylint:disable=unused-argument
if _AccessToken is None: # import failed
raise ImportError("You need to install 'azure-core' to use CLI credentials in this context")

if len(scopes) != 1:
raise ValueError("Multiple scopes are not supported: {}".format(scopes))
scope = scopes[0]
if scope.endswith(self._DEFAULT_PREFIX):
resource = scope[:-len(self._DEFAULT_PREFIX)]
else:
resource = scope
resource = self._profile.cli_ctx.cloud.endpoints.active_directory_resource_id
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need scopes any more?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We extract it from CLI profile


credentials = self._get_cred(resource)
_, token, fulltoken = credentials._token_retriever() # pylint:disable=protected-access
Expand Down