Spotify media library does not work at all. It used to work, but I lost track which version was the last version confirmed working for me. Apparently the integration does not support media browsing according to the logs.
configuration.yaml
2020-10-19 10:02:36 ERROR (MainThread) [homeassistant.components.media_player] media_player.spotify_X allows media browsing but its integration (spotify) does not
When I press the media browsing button, the frontend gets stuck and the only way to get it to work is by refreshing the page.
Hey there @frenck, mind taking a look at this issue as its been labeled with an integration (spotify) you are listed as a codeowner for? Thanks!
(message by CodeOwnersMention)
spotify documentation
spotify source
(message by IssueLinks)
Sooooooooooo? What are the next steps here?
@OGKevin Can you please provide more details what does not work and how to reproduce? For me, browsing the Spotify library works just fine.
hmm what more details are you looking for? I can't think of any details that I left out. Literally all I do is press the little media player icon and that log entry appears in the logs. The media lib itself never appears.
I could ultimately try deleting and re-adding the integration. Does this integration spit out debug logs? I can try and enable debug log and see if more info is spit out in the logs.
With "little icon" you mean the one in the sidebar or are you navigating via a media player card or more-info dialog?
Does the same error happen if in the "Media Browser" panel you user "Choose Player" to select your local media folder and then go back to Spotify again?
And yes, the Spotify integration has some debug logger statements that might reveal some more details, so please enable the debug logging and let us know.
With the little icon I mean this one:

Does the same error happen if in the "Media Browser" panel you user "Choose Player" to select your local media folder and then go back to Spotify again?
Yes
And yes, the Spotify integration has some debug logger statements that might reveal some more details, so please enable the debug logging and let us know
Can you give me a hint on how to turn it oh 馃. I've tried homeassistant.components.media_player: debug but seems that this is not correct.
logger:
default: info
logs:
homeassistant.components.media_player: debug
Can you try homeassistant.components.spotify: debug. But in the end there might not be anything additional in the log, if the places that would create debug output are not actually hit.
Hmm that debug option also does not log anything else than what I've already posted.
I'm having the same problem (both via cards and Media Browser link in the sidebar). Nothing additional in the logs beyond what's been mentioned already by OGKevin.
Strangely, it was working a few days ago on 0.116 and stopped out of the blue. I've since updated to 0.117.2 and still having the same issue. I'd put it down to an API change if it weren't for the fact OGKevin's stopped almost a fortnight before mine did.
I had a more detailed look at the coding. This exception in the Spotify context will appear if the "scopes" of the session token are not matching what the integration expects.
https://github.com/home-assistant/core/blob/bfc3d3be764123adb147d39d73b87c2e9e9d9673/homeassistant/components/spotify/media_player.py#L221
Those scope values are stored in the HA core.config_entries. So removing and re-adding the integration might work (hoping that then it pulls the correct scope attributes). Or as a test manually setting the values in the config file:
"scope": "playlist-read-private playlist-read-collaborative user-modify-playback-state user-library-read user-follow-read user-read-playback-state user-read-recently-played user-read-playback-position user-read-private user-top-read"
Aha. Removing and re-adding the integration does the trick. If it had the correct scopes originally and again has the correct scopes now, I wonder why there was a period of not having them.
Can confirm removing and re-adding integration worked. Shall we add a line to the log to to give this solution as a hint?
I was thinking the same. Do you want to tackle that or should I create a PR?
I would love to do it! 馃槉
For reference. Today I'm getting the same error. Even after re-adding it before like @spacegaier suggested. So it might be a deeper issue 馃.
Some more info:
Logger: spotipy.client
Source: /usr/local/lib/python3.8/site-packages/spotipy/client.py:258
First occurred: 4:44:03 (5 occurrences)
Last logged: 20:03:55
HTTP Error for GET to https://api.spotify.com/v1/me/player/devices returned 401 due to The access token expired
I think I know what is going on. I need to dome some debugging to determine if my theory is correct and provide a valid fix other than just a simple log entry. But I think that the code that triggers re-auth is faulty. In theory when you reboot Hassio this code: https://github.com/home-assistant/core/blob/bf9f3e1997a56760b9f378a38547149264928436/homeassistant/components/spotify/__init__.py#L80-L87 should trigger a re-auth but its not the case for he.
There is one extra scope returned from the API that is not in the list. The 2 conditions are not the same hence the check is failing. The one check if the list is exactly the same while the other one checks if its a superset.
@frenck Is there a specific reason why the 2 conditionals are diff?
https://github.com/home-assistant/core/blob/5a7e4b4dae8d291a53805b646a725202ffb8000c/homeassistant/components/spotify/__init__.py#L80
vs
If not, then ill change the PR to make them the same 馃槉

Most helpful comment
I had a more detailed look at the coding. This exception in the Spotify context will appear if the "scopes" of the session token are not matching what the integration expects.
https://github.com/home-assistant/core/blob/bfc3d3be764123adb147d39d73b87c2e9e9d9673/homeassistant/components/spotify/media_player.py#L221
Those scope values are stored in the HA
core.config_entries. So removing and re-adding the integration might work (hoping that then it pulls the correct scope attributes). Or as a test manually setting the values in the config file: