Skip to content

Commit

Permalink
fix autorize() checks
Browse files Browse the repository at this point in the history
  • Loading branch information
cbini committed Feb 15, 2022
1 parent 5e0bc7d commit 62614a0
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions powerschool/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,15 @@ def __init__(self, host, **kwargs):

def authorize(self, auth):
""""""
# access token (dict)
if isinstance(auth, dict):
if isinstance(auth, dict): # access token (dict)
# check if access token is still valid
expires_at = datetime.fromtimestamp(auth.get("expires_at"))
now = datetime.now()
if expires_at > now:
self.access_token = auth
else:
raise TokenExpiredError("Access token expired!")

# client credentials (tuple)
if isinstance(auth, tuple):
elif isinstance(auth, tuple): # client credentials (tuple)
# fetch new access token
token_url = f"{self.base_url}/oauth/access_token/"
client_id, client_secret = auth
Expand Down

0 comments on commit 62614a0

Please sign in to comment.