Skip to content

Commit

Permalink
Handle token exiration time not being correct type
Browse files Browse the repository at this point in the history
  • Loading branch information
nickknissen committed Jul 12, 2023
1 parent a4508ab commit 25c1a85
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion custom_components/monta/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,11 @@ def _is_access_token_valid(self):
if self._prefs[STORAGE_ACCESS_EXPIRE_TIME] is None:
return False

_LOGGER.debug("[_is_access_token_valid] STORAGE_ACCESS_EXPIRE_TIME: %s, type: %s", self._prefs[STORAGE_ACCESS_EXPIRE_TIME], type(self._prefs[STORAGE_ACCESS_EXPIRE_TIME]))

if not isinstance(self._prefs[STORAGE_ACCESS_EXPIRE_TIME], str):
return False

expire_time = dt_util.parse_datetime(self._prefs[STORAGE_ACCESS_EXPIRE_TIME])
preemptive_expire_time = expire_time - timedelta(
seconds=PREEMPTIVE_REFRESH_TTL_IN_SECONDS
Expand All @@ -295,7 +300,12 @@ def _is_refresh_token_valid(self):
if not self._prefs[STORAGE_REFRESH_TOKEN]:
return False

if self._prefs[STORAGE_ACCESS_EXPIRE_TIME] is None:
if self._prefs[STORAGE_REFRESH_EXPIRE_TIME] is None:
return False

_LOGGER.debug("[_is_refresh_token_valid] STORAGE_REFRESH_EXPIRE_TIME: %s, type: %s", self._prefs[STORAGE_ACCESS_EXPIRE_TIME], type(self._prefs[STORAGE_REFRESH_EXPIRE_TIME]))

if not isinstance(self._prefs[STORAGE_REFRESH_EXPIRE_TIME], str):
return False

expire_time = dt_util.parse_datetime(self._prefs[STORAGE_REFRESH_EXPIRE_TIME])
Expand Down

0 comments on commit 25c1a85

Please sign in to comment.