Skip to content

get_access_token: error checking #1841

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

Open
wants to merge 2 commits 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 @@ -62,6 +62,14 @@ def get_access_token(self, force_refresh: bool = False) -> str:
auth_token = self.__get_msal_app().acquire_token_for_client(
scopes=self.scopes
)

# acquire_token...() returns None if there are no any tokens and
# a dict which contains 'error' in case of error
if auth_token is None:
raise UserWarning("No any access tokens")
if 'error' in auth_token:
raise UserWarning(f"Failed to get access token: {auth_token}")

return auth_token["access_token"]

def __get_msal_app(self):
Expand Down