10000 Raise PermissionError if access_token not available on auth_token obj… · ultrarslanoglu/botbuilder-python@cea5ccc · GitHub
[go: up one dir, main page]

Skip to content

Commit cea5ccc

Browse files
authored
Raise PermissionError if access_token not available on auth_token object (microsoft#2138)
1 parent a7fd439 commit cea5ccc

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

libraries/botframework-connector/botframework/connector/auth/microsoft_app_credentials.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,12 @@ def get_access_token(self, force_refresh: bool = False) -> str:
5252
if not auth_token:
5353
# No suitable token exists in cache. Let's get a new one from AAD.
5454
auth_token = self.__get_msal_app().acquire_token_for_client(scopes=scopes)
55-
return auth_token["access_token"]
55+
if "access_token" in auth_token:
56+
return auth_token["access_token"]
57+
else:
58+
error = auth_token["error"] if "error" in auth_token else "Unknown error"
59+
error_description = auth_token["error_description"] if "error_description" in auth_token else "Unknown error description"
60+
raise PermissionError(f"Failed to get access token with error: {error}, error_description: {error_description}")
5661

5762
def __get_msal_app(self):
5863
if not self.app:

0 commit comments

Comments
 (0)
0