mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 22:27:07 +00:00
Guard for when refreshing token fails (#43855)
This commit is contained in:
parent
15b5057569
commit
06626af337
@ -1,5 +1,6 @@
|
|||||||
"""The spotify integration."""
|
"""The spotify integration."""
|
||||||
|
|
||||||
|
import aiohttp
|
||||||
from spotipy import Spotify, SpotifyException
|
from spotipy import Spotify, SpotifyException
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
@ -62,7 +63,12 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
"""Set up Spotify from a config entry."""
|
"""Set up Spotify from a config entry."""
|
||||||
implementation = await async_get_config_entry_implementation(hass, entry)
|
implementation = await async_get_config_entry_implementation(hass, entry)
|
||||||
session = OAuth2Session(hass, entry, implementation)
|
session = OAuth2Session(hass, entry, implementation)
|
||||||
await session.async_ensure_token_valid()
|
|
||||||
|
try:
|
||||||
|
await session.async_ensure_token_valid()
|
||||||
|
except aiohttp.ClientError as err:
|
||||||
|
raise ConfigEntryNotReady from err
|
||||||
|
|
||||||
spotify = Spotify(auth=session.token["access_token"])
|
spotify = Spotify(auth=session.token["access_token"])
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user