# Spotify authentication works only after server restart

**URL:** <https://discourse.mopidy.com/t/spotify-authentication-works-only-after-server-restart/3617>\
**Category:** Misc\
**Created:** [December 8, 2019, 11:06am UTC](https://discourse.mopidy.com/t/spotify-authentication-works-only-after-server-restart/3617 "2019-12-08T11:06:27Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Christopher\_Hut](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.mopidy.com/christopher_hut/32/1359_2.png) [@Christopher\_Hut](https://discourse.mopidy.com/u/Christopher_Hut)\
**Post date:** [December 8, 2019, 11:06am UTC](https://discourse.mopidy.com/t/spotify-authentication-works-only-after-server-restart/3617/1 "2019-12-08T11:06:27Z")

</div>

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:

- I start the Raspberry
- I open [http://192.168.178.36:6680/iris/library/albums](http://192.168.178.36:6680/iris/library/albums)  
 → Albums linked my Spotify account are shown
- I select an album an clock on play  
 → Error message “Mopidy: Failed to add some tracks”

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](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.

---

<div class="post-metadata">

**Author:** ![kingosticks](https://avatars.discourse-cdn.com/v4/letter/k/858c86/32.png) [@kingosticks](https://discourse.mopidy.com/u/kingosticks)\
**Post date:** [December 8, 2019, 11:30am UTC](https://discourse.mopidy.com/t/spotify-authentication-works-only-after-server-restart/3617/2 "2019-12-08T11:30:41Z")

</div>

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/](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.

---

<div class="post-metadata">

**Author:** ![Christopher\_Hut](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.mopidy.com/christopher_hut/32/1359_2.png) [@Christopher\_Hut](https://discourse.mopidy.com/u/Christopher_Hut)\
**Post date:** [December 8, 2019, 11:45am UTC](https://discourse.mopidy.com/t/spotify-authentication-works-only-after-server-restart/3617/3 "2019-12-08T11:45:40Z")

</div>

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 =

---

<div class="post-metadata">

**Author:** ![Christopher\_Hut](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.mopidy.com/christopher_hut/32/1359_2.png) [@Christopher\_Hut](https://discourse.mopidy.com/u/Christopher_Hut)\
**Post date:** [December 8, 2019, 2:30pm UTC](https://discourse.mopidy.com/t/spotify-authentication-works-only-after-server-restart/3617/4 "2019-12-08T14:30:52Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Christopher\_Hut](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.mopidy.com/christopher_hut/32/1359_2.png) [@Christopher\_Hut](https://discourse.mopidy.com/u/Christopher_Hut)\
**Post date:** [December 9, 2019, 5:09am UTC](https://discourse.mopidy.com/t/spotify-authentication-works-only-after-server-restart/3617/5 "2019-12-09T05:09:49Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jodal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.mopidy.com/jodal/32/2651_2.png) [@jodal](https://discourse.mopidy.com/u/jodal)\
**Post date:** [December 9, 2019, 7:42am UTC](https://discourse.mopidy.com/t/spotify-authentication-works-only-after-server-restart/3617/6 "2019-12-09T07:42:16Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![kingosticks](https://avatars.discourse-cdn.com/v4/letter/k/858c86/32.png) [@kingosticks](https://discourse.mopidy.com/u/kingosticks)\
**Post date:** [December 9, 2019, 8:55am UTC](https://discourse.mopidy.com/t/spotify-authentication-works-only-after-server-restart/3617/7 "2019-12-09T08:55:58Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Christopher\_Hut](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.mopidy.com/christopher_hut/32/1359_2.png) [@Christopher\_Hut](https://discourse.mopidy.com/u/Christopher_Hut)\
**Post date:** [December 9, 2019, 7:17pm UTC](https://discourse.mopidy.com/t/spotify-authentication-works-only-after-server-restart/3617/8 "2019-12-09T19:17:27Z")

</div>

Ha, fantastic!  
That one resolved the issue.

Thanks for the help!

---

<div class="post-metadata">

**Author:** ![Christopher\_Hut](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.mopidy.com/christopher_hut/32/1359_2.png) [@Christopher\_Hut](https://discourse.mopidy.com/u/Christopher_Hut)\
**Post date:** [December 9, 2019, 7:19pm UTC](https://discourse.mopidy.com/t/spotify-authentication-works-only-after-server-restart/3617/9 "2019-12-09T19:19:07Z")

</div>

Hi,.  
I was in general referring to the following thread: [Raspberry Pi 4 support?](https://discourse.mopidy.com/t/raspberry-pi-4-support/3348)

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