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

Port auth error handling from microsoft_app_credentials to certificate_app_credentials #2196

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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 @@ -67,7 +67,17 @@ def get_access_token(self, force_refresh: bool = False) -> str:
if not auth_token:
# No suitable token exists in cache. Let's get a new one from AAD.
auth_token = self.__get_msal_app().acquire_token_for_client(scopes=scopes)
return auth_token["access_token"]
if "access_token" in auth_token:
return auth_token["access_token"]
error = auth_token["error"] if "error" in auth_token else "Unknown error"
error_description = (
auth_token["error_description"]
if "error_description" in auth_token
else "Unknown error description"
)
raise PermissionError(
f"Failed to get access token with error: {error}, error_description: {error_description}"
)

def __get_msal_app(self):
if not self.app:
Expand Down