Skip to content

Commit

Permalink
removing token on error to retry automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
kloknibor committed Apr 21, 2023
1 parent 1972140 commit 98891c9
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions custom_components/miele/miele_at_home.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,12 @@ async def refresh_token(self, hass):
self._save_token(self._token)

def sync_refresh_token(self, token_url, body, refresh_token):
return self._session.refresh_token(
token_url, body=body, refresh_token=refresh_token
)
try:
return self._session.refresh_token(
token_url, body=body, refresh_token=refresh_token
)
except:
self._remove_token()

def _get_cached_token(self):
token = None
Expand Down Expand Up @@ -226,3 +229,14 @@ def _save_token(self, token):
pass

self._token = token

def _remove_token(self):
_LOGGER.debug("trying to REMOVE token to create it again on next startup so please re-startup and try again!")
if self._cache_path:
try:
os.remove(self._cache_path)
except IOError:
_LOGGER._warn(
"Couldn't delte token cache to {0}".format(self._cache_path)
)
pass

0 comments on commit 98891c9

Please sign in to comment.