mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Fix Spotify session token refresh (#66390)
This commit is contained in:
parent
cb7f7dff72
commit
10c7725a90
@ -121,6 +121,12 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
raise ConfigEntryNotReady from err
|
raise ConfigEntryNotReady from err
|
||||||
|
|
||||||
async def _update_devices() -> list[dict[str, Any]]:
|
async def _update_devices() -> list[dict[str, Any]]:
|
||||||
|
if not session.valid_token:
|
||||||
|
await session.async_ensure_token_valid()
|
||||||
|
await hass.async_add_executor_job(
|
||||||
|
spotify.set_auth, session.token["access_token"]
|
||||||
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
devices: dict[str, Any] | None = await hass.async_add_executor_job(
|
devices: dict[str, Any] | None = await hass.async_add_executor_job(
|
||||||
spotify.devices
|
spotify.devices
|
||||||
|
@ -515,9 +515,7 @@ class SpotifyMediaPlayer(MediaPlayerEntity):
|
|||||||
run_coroutine_threadsafe(
|
run_coroutine_threadsafe(
|
||||||
self._session.async_ensure_token_valid(), self.hass.loop
|
self._session.async_ensure_token_valid(), self.hass.loop
|
||||||
).result()
|
).result()
|
||||||
self._spotify_data[DATA_SPOTIFY_CLIENT] = Spotify(
|
self._spotify.set_auth(auth=self._session.token["access_token"])
|
||||||
auth=self._session.token["access_token"]
|
|
||||||
)
|
|
||||||
|
|
||||||
current = self._spotify.current_playback()
|
current = self._spotify.current_playback()
|
||||||
self._currently_playing = current or {}
|
self._currently_playing = current or {}
|
||||||
@ -581,7 +579,11 @@ async def async_browse_media_internal(
|
|||||||
partial(library_payload, can_play_artist=can_play_artist)
|
partial(library_payload, can_play_artist=can_play_artist)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if not session.valid_token:
|
||||||
await session.async_ensure_token_valid()
|
await session.async_ensure_token_valid()
|
||||||
|
await hass.async_add_executor_job(
|
||||||
|
spotify.set_auth, session.token["access_token"]
|
||||||
|
)
|
||||||
|
|
||||||
# Strip prefix
|
# Strip prefix
|
||||||
media_content_type = media_content_type[len(MEDIA_PLAYER_PREFIX) :]
|
media_content_type = media_content_type[len(MEDIA_PLAYER_PREFIX) :]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user