Skip to content

Commit

Permalink
Add function to verify if we can login
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshua Mulliken committed Apr 10, 2021
1 parent cfb192d commit d2c2b51
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/wyzeapy/base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class BaseClient:
access_token = ""
refresh_token = ""

def login(self, email, password) -> None:
def login(self, email, password) -> bool:
email = email
password = password

Expand All @@ -111,9 +111,15 @@ def login(self, email, password) -> None:

response_json = requests.post("https://auth-prod.api.wyze.com/user/login",
headers=headers, json=login_payload).json()

self.access_token = response_json['access_token']
self.refresh_token = response_json['refresh_token']
try:
self.access_token = response_json['access_token']
self.refresh_token = response_json['refresh_token']
return True
except KeyError:
return False

def can_login(self, username, password):
return self.login(username, password)

@staticmethod
def create_password(password) -> str:
Expand Down

0 comments on commit d2c2b51

Please sign in to comment.