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
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,5 @@ def _get_error_message(history):
attempts.append("{}: {}".format(credential.__class__.__name__, error))
else:
attempts.append(credential.__class__.__name__)
return "No valid token received. {}".format(". ".join(attempts))
return """No credential in this chain provided a token.
Attempted credentials:\n\t{}""".format("\n\t".join(attempts))
12 changes: 12 additions & 0 deletions sdk/identity/azure-identity/azure/identity/_credentials/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
# ------------------------------------
import os

from azure.core.exceptions import ClientAuthenticationError

from .._constants import EnvironmentVariables
from .chained import ChainedTokenCredential
from .environment import EnvironmentCredential
Expand Down Expand Up @@ -42,3 +44,13 @@ def __init__(self, **kwargs):
)

super(DefaultAzureCredential, self).__init__(*credentials)

def get_token(self, *scopes, **kwargs):
try:
return super(DefaultAzureCredential, self).get_token(*scopes, **kwargs)
except ClientAuthenticationError as e:
raise ClientAuthenticationError(message="""
{}\n\nPlease visit the Azure identity Python SDK docs at
https://aka.ms/python-sdk-identity#defaultazurecredential
to learn what options DefaultAzureCredential supports"""
.format(e.message))