Spotify authentication works only after server restart

Hi all,

I’m another one, who is new to this and I have the issue, that the Spotify Authentication only works, after restarting the server.

Below you find details on how to reproduce the issue:

The logs say:

2019-12-08 11:58:45,309 INFO [497:SpotifyBackend-3] mopidy_spotify.lookup: Failed to lookup “spotify:album:1SvXpumbe1NKEzOAyMjfGT”: Session must be logged in and online to load objects: <ConnectionState.LOGGED_OUT: 0>

Going back some minutes in the log, it gives me. So there is some authentication issue.

2019-12-08 11:40:41,368 ERROR [497:SpotifyEventLoop] spotify.session: Spotify login error: <ErrorType.OTHER_PERMANENT: 10>
2019-12-08 11:40:41,370 INFO [497:SpotifyEventLoop] spotify.session: Spotify logged out
2019-12-08 11:40:42,872 ERROR [497:SpotifyBackend-3] mopidy_spotify.web: OAuth token refresh failed: Unknown error.
2019-12-08 11:40:42,872 ERROR [497:SpotifyBackend-3] mopidy_spotify.web: Failed to load Spotify user profile

But if I restart the server (Settings (http://192.168.178.36:6680/iris/settings) and click on “Restart Server”) the log says:

2019-12-08 12:01:51,288 INFO [2544:SpotifyEventLoop] spotify.session: Spotify logged in
2019-12-08 12:01:51,290 INFO [2544:SpotifyEventLoop] mopidy_spotify.backend: Logged in to Spotify in online mode
2019-12-08 12:01:51,861 INFO [2544:SpotifyBackend-3] mopidy_spotify.web: Logged into Spotify Web API as m0t0slkutgqsjw6lg48qli1wi
2019-12-08 12:01:51,865 INFO [2544:SpotifyBackend-3] mopidy_spotify.backend: Started spotify backend

Now I can go to Albums, select one and click on play → No error, everything works.

I have to do this everytime I restart the Raspberry.

Does anybody have an idea where to search for the issue?

Thank you for the help.

If you want to play music from Spotify you need to have all the required authentication details in your Mopidy config file, as details on the readme. The location of that file depends on if you run Mopidy as a service or not (http://docs.mopidy.com/en/latest/service/). You can use sudo mopidyctl config to check it’s all correct. Once that’s done iris (and any other webclient) should just work.

HI,

but if the config for authentication is wrong, why does is work, as I restart the server?

The spotify part in the config does not look different to me, than other ones I have seen on the board:

[spotify]
enabled = true
username = john.muetze***
password = ********
client_id = 8b3f28ef-c20e-47f5-942d-48df0c40****
client_secret = ********
bitrate = 160
volume_normalization = true
private_session = false
timeout = 10
allow_cache = true
allow_network = true
allow_playlists = true
search_album_count = 20
search_artist_count = 10
search_track_count = 50
toplist_countries =

To try different thinks, I went to the spotify account overview and tried both, Username and email. Both resulted in the same authentication error.
After restart of the server it works in both options.

Another Thing I will try: I am curreblntly running on a Raspberry 4. I have seen, that this is Not fully supported.

I will try a Raspberry 3 this week and hope that this May resolve the issue.

I am still positive that this is Not an issue with the credentials.

I’m not familiar with any incompatibility with Raspberry Pi 4, at least not anything working better on Raspberry Pi 3. If so, that would be something we’d like to look into and solve. Can you elaborate on what you’re referring to?

Could this be an issue with the network not yet being available when Mopidy starts? I think there is an option somewhere (raspi-config maybe?) for the Pi to wait until network is ready during boot. Can you try that please?

1 Like

Ha, fantastic!
That one resolved the issue.

Thanks for the help!

Hi,.
I was in general referring to the following thread: Raspberry Pi 4 support?

But as it showed, this is not relevant for the issue on hand.