Spotify set up error

Hi,
I followed the HA guide: Spotify Integration
but I got the next error. I double checked the Spotify Developer client ID and the secret token and restarted HA several times, but the problem persists . Any ideas?

My configuration.yaml:

spotify:
  client_id: !secret spotify_client_id
  client_secret: !secret spotify_secret

The error:
image

Logger: homeassistant.config_entries
Source: components/cloud/account_link.py:147
First occurred: 13:42:50 (1 occurrences)
Last logged: 13:42:50

Error setting up entry j... 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'
2 Likes

Hi, I also have the same problem. It appears to be a bug… I filed an issue to the repo, hopefully the developers might know what’s wrong. Spotify fails after linking · Issue #53375 · home-assistant/core · GitHub

2 Likes

Same issue here. Will monitor thread.

Same, mine works fine when I initally add the integration, but within an hour or so it fails to connect… restart of HA yields errors setting up the component.

I’m also unclear if the manual steps of creating the app in the Spotify developer page are still required too… as I hadn’t read that to start with and just added the integration via the HA UI, it got me to login and link Spotify, after which it worked (for a little bit) :stuck_out_tongue:

Same here, works fine initially, but then suddenly stops working with the error mentioned above.

Same problem here, most likely a bug.

For me, this is the solution: https://github.com/home-assistant/core/issues/53375#issuecomment-886052779.
Thanks to @vmartinv.
After I followed this instructions I installed the Spotcast integration (HACS) to works with my inactive Google Home and Chromecast, and works fine.

Test:

service: spotcast.start
data:
  entity_id: media_player.altavoz_escritorio
  uri: spotify:playlist:37i9dQZF1DXagWh7Ah6GLg

I have a slightly dissimilar experience. I too get the same error, however when I delete the integration and add it back in, I am redirected to NabuCasa saying that my account is now linked. Wait a few hours add Spotify is broken again. I am prompted to setup Spotify again. Logs show ‘Error setting up entry user for Spotify’

image

I have the same error! The integration is working with the cloud connection, even if I don’t signed up for the Home Assistant cloud integration :thinking:

Add one more to the list. Worked on initial integration but subsequent reboots show this status.

Integration works fine, but after a while -Failed to set up-

1 Like

+1, exact issue as described here.

1 Like

A fix was added in Home Assistant core 2021.8.0, try updating. If that doesn’t work follow the steps I mentioned.

Tried to add the spotify integration again. But now I get “Aborted” looking in the log:

Max Retries reached
9:13:41 – (ERROR) /usr/local/lib/python3.9/site-packages/spotipy/client.py - message first occurred at 9:03:10 and shows up 4 times

Exact same problem here…

Also having the exact same problem

I had this error as well after updating to 2021.8.8.

Following the manual steps (getting Client_ID and Client_Secret from Spotify Developer and putting it in configuration.yaml) worked for me (at least on the short term, let’s see if it fails after some time again):

1 Like

Retrying setup: http status: 429, code:-1 - /v1/me/: Max Retries, reason: too many 429 error responses

1 Like

This worked for me also

how did you fix it ?

Logger: spotipy.client
Source: /usr/local/lib/python3.9/site-packages/spotipy/client.py:270
First occurred: 23:22:10 (15 occurrences)
Last logged: 23:37:12

Max Retries reached

Do i need to redo the pairing ? or what is the problem ?

What i did:
i put my spotify login in the config tab.
i put my DEV Token/User in the config.yaml
i put my IP in the Callback on Spotify DEV. (Redirect URIs)
i restarted HA

EDIT:
i got it, i found this:

I think that the issue happens when you link the account before adding your developer credentials to the config. The reason I did this is because in the UI it never asked me to and I haven’t. I added my credentials (client id and client secret), reinstalled the app and relinked my account, and so far it’s been working. Let me know if this works.
IMO, there should be a check for the credentials before attempting to link the account.

4 Likes