Skip to content

Commit

Permalink
Merge pull request #201 from natekspencer/dev
Browse files Browse the repository at this point in the history
Add additional logging
  • Loading branch information
natekspencer authored Oct 8, 2024
2 parents 6c96e5b + 5c7dfd0 commit 3b01344
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions vivintpy/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 4 additions & 0 deletions vivintpy/vivintskyapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 3b01344

Please sign in to comment.