Skip to content

Commit 25c1a85

Browse files
committed
Handle token exiration time not being correct type
1 parent a4508ab commit 25c1a85

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

custom_components/monta/api.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,11 @@ def _is_access_token_valid(self):
283283
if self._prefs[STORAGE_ACCESS_EXPIRE_TIME] is None:
284284
return False
285285

286+
_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]))
287+
288+
if not isinstance(self._prefs[STORAGE_ACCESS_EXPIRE_TIME], str):
289+
return False
290+
286291
expire_time = dt_util.parse_datetime(self._prefs[STORAGE_ACCESS_EXPIRE_TIME])
287292
preemptive_expire_time = expire_time - timedelta(
288293
seconds=PREEMPTIVE_REFRESH_TTL_IN_SECONDS
@@ -295,7 +300,12 @@ def _is_refresh_token_valid(self):
295300
if not self._prefs[STORAGE_REFRESH_TOKEN]:
296301
return False
297302

298-
if self._prefs[STORAGE_ACCESS_EXPIRE_TIME] is None:
303+
if self._prefs[STORAGE_REFRESH_EXPIRE_TIME] is None:
304+
return False
305+
306+
_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]))
307+
308+
if not isinstance(self._prefs[STORAGE_REFRESH_EXPIRE_TIME], str):
299309
return False
300310

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

0 commit comments

Comments
 (0)