Skip to content

Commit

Permalink
Continued error handling cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
liquidz00 committed Jun 9, 2024
1 parent 47f739b commit 4563a2b
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions bin/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,17 +163,16 @@ async def fetch_token() -> Optional[AnyStr]:
response.raise_for_status()
except aiohttp.ClientResponseError as e:
logthis.warn(f"Failed to fetch bearer token. Status code: {e.status}")
else:
json_response = await response.json()
token = json_response.get("access_token", "")
expires = int(json_response.get("expires_in", 0))
if not token or not expires:
return None
update_env(token=token, expires_in=expires)
logthis.info(f"Token obtained successfully. Expires in {expires} seconds")
return token

return None
return None

json_response = await response.json()
token = json_response.get("access_token", "")
expires = int(json_response.get("expires_in", 0))
if not token or not expires:
return None
update_env(token=token, expires_in=expires)
logthis.info(f"Token obtained successfully. Expires in {expires} seconds")
return token


# Async API call
Expand Down

0 comments on commit 4563a2b

Please # to comment.