diff --git a/libraries/botframework-connector/botframework/connector/auth/microsoft_app_credentials.py b/libraries/botframework-connector/botframework/connector/auth/microsoft_app_credentials.py index d625d6ede..cfe6c18e2 100644 --- a/libraries/botframework-connector/botframework/connector/auth/microsoft_app_credentials.py +++ b/libraries/botframework-connector/botframework/connector/auth/microsoft_app_credentials.py @@ -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):