it it normal that the tokens expired after a few weeks or something like that? do we need to remove/readd the integration once every few weeks? i always notice this in log below
2020-09-30 21:53:52 ERROR (SyncWorker_1) [spotipy.client] HTTP Error for GET to https://api.spotify.com/v1/me/ returned 401 due to The access token expired
2020-09-30 21:53:52 WARNING (MainThread) [homeassistant.config_entries] Config entry for spotify not ready yet. Retrying in 80 seconds
2020-09-30 21:55:12 ERROR (SyncWorker_32) [spotipy.client] HTTP Error for GET to https://api.spotify.com/v1/me/ returned 401 due to The access token expired
2020-09-30 21:55:12 WARNING (MainThread) [homeassistant.config_entries] Config entry for spotify not ready yet. Retrying in 80 seconds
2020-09-30 21:56:32 ERROR (SyncWorker_15) [spotipy.client] HTTP Error for GET to https://api.spotify.com/v1/me/ returned 401 due to The access token expired
2020-09-30 21:56:32 WARNING (MainThread) [homeassistant.config_entries] Config entry for spotify not ready yet. Retrying in 80 seconds
2020-09-30 21:57:52 ERROR (SyncWorker_16) [spotipy.client] HTTP Error for GET to https://api.spotify.com/v1/me/ returned 401 due to The access token expired
2020-09-30 21:57:52 WARNING (MainThread) [homeassistant.config_entries] Config entry for spotify not ready yet. Retrying in 80 seconds
2020-09-30 21:59:12 ERROR (SyncWorker_6) [spotipy.client] HTTP Error for GET to https://api.spotify.com/v1/me/ returned 401 due to The access token expired
2020-09-30 21:59:12 WARNING (MainThread) [homeassistant.config_entries] Config entry for spotify not ready yet. Retrying in 80 seconds
Do we possibly need our HA instances to be accessable from the internet?
That might be a cause for the authorization expiration (home assistant spotify " HTTP Error for GET to https://api.spotify.com/v1/me/player/devices returned 401 due to The access token expired "). My HA instance is not accessable from the internet - which includes Spotify API. I have no external_url configured in HA.
After fresh integration using the UI it works for some time, than dies - and fills the HA log massively afterwards (with loads of Update for media_player.spotify fails).
What about you @pergola.fabio + @MrBenedict + @heachhog ? Is your HA connected to the internet e. g. via Nabu Casa, DuckDNS or other reverse proxy setup?
i am having the same problem here aswell, the intergration work after installation but dies over some hours. i checked my logs and get this
Error setting up entry Vincent for spotify
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 293, in async_setup
result = await component.async_setup_entry(hass, self) # type: ignore
File "/usr/src/homeassistant/homeassistant/components/spotify/__init__.py", line 70, in async_setup_entry
await session.async_ensure_token_valid()
File "/usr/src/homeassistant/homeassistant/helpers/config_entry_oauth2_flow.py", line 464, in async_ensure_token_valid
new_token = await self.implementation.async_refresh_token(self.token)
File "/usr/src/homeassistant/homeassistant/helpers/config_entry_oauth2_flow.py", line 88, in async_refresh_token
new_token = await self._async_refresh_token(token)
File "/usr/src/homeassistant/homeassistant/components/cloud/account_link.py", line 147, in _async_refresh_token
self.hass.data[DOMAIN], self.service, token["refresh_token"]
KeyError: 'refresh_token'
i i reinstall the spotify intergration it will work again (then dies) i am running my hass via DuckDNS and configurated the internal ip aswell.
Is your HA accessable from the internet? I guess the redirect URI in Spotify - Home Assistant doesn´t accept (or it will stop working) local names like https://my-local-homeassistant.fritz.box.
By the way the official Spotify integration meanwhile automatically does exactly what Spotify - Home Assistant describes step by step. Should therefore make no difference if you create the HA app in spotify dev dashboard on your own. If if fails after some time it is because of a different reason - and I strongly suspect the need for having a redirect URI / Home Assistant publicly accessable so Spotify Cloud can connect to it.
If that´s true → interestingly I saw no “prerequisite” section with that information. They only talk about a Spotify (premium) account and the app (which is created automatically meanwhile) at Spotify - Home Assistant …
yea my hass i accessable form the internet via duckdns, and since i made the application on the dev dashboard on spotify its been working perfect for the last couple of days (tried to replicate the issue). and i also am using spotify premium from a family bundle. (im not the owner of the family subscription)