8000 Port auth error handling from microsoft_app_credentials to certificat… · rrosajp/botbuilder-python@ef5ecd3 · GitHub
[go: up one dir, main page]

Skip to content

Commit ef5ecd3

Browse files
kostyaplisKonstantin Plis
and
Konstantin Plis
authored
Port auth error handling from microsoft_app_credentials to certificate_app_credentials (microsoft#2196)
Co-authored-by: Konstantin Plis <konstantin.plis@acronis.com>
1 parent a7f5d91 commit
10000
 ef5ecd3

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,17 @@ def get_access_token(self, force_refresh: bool = False) -> str:
6767
if not auth_token:
6868
# No suitable token exists in cache. Let's get a new one from AAD.
6969
auth_token = self.__get_msal_app().acquire_token_for_client(scopes=scopes)
70-
return auth_token["access_token"]
70+
if "access_token" in auth_token:
71+
return auth_token["access_token"]
72+
error = auth_token["error"] if "error" in auth_token else "Unknown error"
73+
error_description = (
74+
auth_token["error_description"]
75+
if "error_description" in auth_token
76+
else "Unknown error description"
77+
)
78+
raise PermissionError(
79+
f"Failed to get access token with error: {error}, error_description: {error_description}"
80+
)
7181

7282
def __get_msal_app(self):
7383
if not self.app:

0 commit comments

Comments
 (0)
0