diff --git a/vivintpy/const.py b/vivintpy/const.py index 6a269a3..328e27e 100644 --- a/vivintpy/const.py +++ b/vivintpy/const.py @@ -5,6 +5,7 @@ class AuthenticationResponse: """Authentication response constants.""" ERROR = "error" + ERROR_DESCRIPTION = "error_description" INVALID = "Invalid username and/or password" MESSAGE = "msg" MFA_REQUIRED = "Multi-factor authentication required" diff --git a/vivintpy/vivintskyapi.py b/vivintpy/vivintskyapi.py index bc05b70..5fb258c 100644 --- a/vivintpy/vivintskyapi.py +++ b/vivintpy/vivintskyapi.py @@ -530,11 +530,13 @@ async def __get_vivintsky_session(self, username: str, password: str) -> None: # Check for TOTP/MFA requirement if "validate" in resp: # SMS/emailed code + _LOGGER.debug("MFA response: %s", resp) self.__mfa_pending = True self.__mfa_type = "code" raise VivintSkyApiMfaRequiredError(AuthenticationResponse.MFA_REQUIRED) if "mfa" in resp: # Authenticator app code + _LOGGER.debug("MFA response: %s", resp) self.__mfa_pending = True self.__mfa_type = "mfa" raise VivintSkyApiMfaRequiredError(AuthenticationResponse.MFA_REQUIRED) @@ -641,6 +643,8 @@ async def __call( ) if not message: message = resp_data.get(AuthenticationResponse.ERROR) + if AuthenticationResponse.ERROR_DESCRIPTION in resp_data: + message = f"{message}: {resp_data[AuthenticationResponse.ERROR_DESCRIPTION]}" if message == AuthenticationResponse.MFA_REQUIRED or is_mfa_request: self.__mfa_pending = True raise VivintSkyApiMfaRequiredError(message)