mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 08:47:57 +00:00
Handle spotify failing to refresh access_token (#9295)
* Handle spotify failing to refresh access_token * Remove whitespace
This commit is contained in:
parent
54de3d89d1
commit
67828cb7a2
@ -148,6 +148,10 @@ class SpotifyMediaPlayer(MediaPlayerDevice):
|
||||
new_token = \
|
||||
self._oauth.refresh_access_token(
|
||||
self._token_info['refresh_token'])
|
||||
# skip when refresh failed
|
||||
if new_token is None:
|
||||
return
|
||||
|
||||
self._token_info = new_token
|
||||
token_refreshed = True
|
||||
if self._player is None or token_refreshed:
|
||||
@ -158,6 +162,12 @@ class SpotifyMediaPlayer(MediaPlayerDevice):
|
||||
def update(self):
|
||||
"""Update state and attributes."""
|
||||
self.refresh_spotify_instance()
|
||||
|
||||
# Don't true update when token is expired
|
||||
if self._oauth.is_token_expired(self._token_info):
|
||||
_LOGGER.warning("Spotify failed to update, token expired.")
|
||||
return
|
||||
|
||||
# Available devices
|
||||
player_devices = self._player.devices()
|
||||
if player_devices is not None:
|
||||
|
Loading…
x
Reference in New Issue
Block a user