Skip to content
Merged
Show file tree
Hide file tree
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
8 changes: 7 additions & 1 deletion src/azure-cli-core/azure/cli/core/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ def _convert_token_entry(token):


def _create_scopes(resource):
scope = resource.rstrip('/') + '/.default'
if resource == 'https://datalake.azure.net/':

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Does datalake endpoint differ in different cloud ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

it only exists in public cloud now

scope = resource + '/.default'
else:
scope = resource.rstrip('/') + '/.default'
return scope


Expand Down Expand Up @@ -54,6 +57,9 @@ def _get_token(self, *scopes):
AuthenticationWrapper._log_hostname()

err = getattr(err, 'message', None) or ''
if 'authentication is required' in err:
raise CLIError("Authentication is migrated to Microsoft identity platform (v2.0). {}".format(
"Please run 'az login' to login." if not in_cloud_console() else ''))
if 'AADSTS70008' in err: # all errors starting with 70008 should be creds expiration related
raise CLIError("Credentials have expired due to inactivity. {}".format(
"Please run 'az login'" if not in_cloud_console() else ''))
Expand Down
2 changes: 1 addition & 1 deletion src/azure-cli-core/azure/cli/core/tests/test_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,7 @@ def test_get_login_credentials_for_data_lake_client(self, get_token):
resource=cli.cloud.endpoints.active_directory_data_lake_resource_id)
_, _ = cred._get_token()
# verify
get_token.assert_called_once_with(mock.ANY, 'https://datalake.azure.net/.default')
get_token.assert_called_once_with(mock.ANY, 'https://datalake.azure.net//.default')
self.assertEqual(tenant_id, self.tenant_id)

@mock.patch('msal.PublicClientApplication.remove_account', autospec=True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -910,7 +910,7 @@ def test_get_login_credentials_for_data_lake_client(self, get_token):
resource=cli.cloud.endpoints.active_directory_data_lake_resource_id)
_, _ = cred._get_token()
# verify
get_token.assert_called_once_with(mock.ANY, 'https://datalake.azure.net/.default')
get_token.assert_called_once_with(mock.ANY, 'https://datalake.azure.net//.default')
self.assertEqual(tenant_id, self.tenant_id)

@mock.patch('msal.PublicClientApplication.remove_account', autospec=True)
Expand Down