Mopidy-Spotify as a service: Login problems

Hello everyone,

I have installed Mopidy and Mopidy-Spotify on my Raspberry Pi 4. It works fine when I start it through the terminal. However, when starting it using systemctl Spotify can’t connect to my account. If I restart the service manually it works fine.

Apr 24 11:58:35 raspberrypi mopidy[463]: ERROR [SpotifyEventLoop] spotify.session Spotify login error: <ErrorType.OTHER_PERMANENT: 10>
Apr 24 11:58:37 raspberrypi mopidy[463]: ERROR [SpotifyBackend-6] mopidy_spotify.web OAuth token refresh failed: Unknown error.
Apr 24 11:58:37 raspberrypi mopidy[463]: ERROR [SpotifyBackend-6] mopidy_spotify.web Failed to load Spotify user profile

I’ve read in this thread that I should change the daemon user from mopidy to root. I’m not sure if this is the same problem. Can you please tell me how to change the daemon user? Is there anything else to solve my problem?

Thank you very much for any help!

Hi, please do not change the user. Is almost never, ever, ever the actual solution.

The normal way to run Mopidy is documented at Running as a service — Mopidy 3.1.1-1-gf17acacf documentation and you can use the commands sudo mopidyctl config and sudo mopidyctl deps to provide debugging info here. Use those commands to ensure you’ve correctly populated the Mopidy-Spotify config settings.

Is there definitely full Internet connectivity at the point Mopidy is starting? If you restart the Mopidy service (command in the docs) do you get the same errors?

Hi, thanks a lot for your quick reply. I guess I should have sent the config rightaway.

I used your documentation to setup the Mopidy service. If I restart the service manually it is working fine. How can I make sure to have full internet connection when Mopidy starts?

[core]
cache_dir = /var/cache/mopidy
config_dir = /etc/mopidy
data_dir = /var/lib/mopidy
max_tracklist_length = 10000
restore_state = false

[logging]
verbosity = 0
format = %(levelname)-8s [%(threadName)s] %(name)s %(message)s
color = false
config_file =

[audio]
mixer = software
mixer_volume =
output = pulsesink server=127.0.0.1
buffer_time =

[proxy]
scheme =
hostname =
port =
username =
password =

[musicbox_webclient]
enabled = true
musicbox = false
websocket_host =
websocket_port =
on_track_click = PLAY_ALL

[mpd]
enabled = true
hostname = ::
port = 6600
password =
max_connections = 20
connection_timeout = 60
zeroconf = Mopidy MPD server on $hostname
command_blacklist =
listall
listallinfo
default_playlist_scheme = m3u

[file]
enabled = true
media_dirs =
$XDG_MUSIC_DIR|Music
~/|Home
excluded_file_extensions =
.directory
.html
.jpeg
.jpg
.log
.nfo
.pdf
.png
.txt
.zip
show_dotfiles = false
follow_symlinks = false
metadata_timeout = 1000

[http]
enabled = true
hostname = 127.0.0.1
port = 6680
zeroconf = Mopidy HTTP server on $hostname
allowed_origins =
csrf_protection = true
default_app = mopidy

[m3u]
enabled = true
base_dir =
default_encoding = latin-1
default_extension = .m3u8
playlists_dir =

[softwaremixer]
enabled = true

[stream]
enabled = true
protocols =
http
https
mms
rtmp
rtmps
rtsp
metadata_blacklist =
timeout = 5000

[spotify]
enabled = true
username = ********
password = ********
client_id = ********
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 =

Running “/usr/bin/mopidy --config /usr/share/mopidy/conf.d:/etc/mopidy/mopidy.conf deps” as user mopidy
Executable: /usr/bin/mopidy
Platform: Linux-5.10.17-v7l±armv7l-with-debian-10.9
Python: CPython 3.7.3 from /usr/lib/python3.7
Mopidy: 3.1.1 from /usr/lib/python3/dist-packages
Mopidy-Spotify: 4.1.0 from /usr/lib/python3/dist-packages
Mopidy-MusicBox-Webclient: 3.1.0 from /usr/local/lib/python3.7/dist-packages
Mopidy: 3.1.1 from /usr/lib/python3/dist-packages
Pykka: 2.0.3 from /usr/lib/python3/dist-packages
setuptools: 40.8.0 from /usr/lib/python3/dist-packages
Mopidy-MPD: 3.1.0 from /usr/local/lib/python3.7/dist-packages
Mopidy: 3.1.1 from /usr/lib/python3/dist-packages
Pykka: 2.0.3 from /usr/lib/python3/dist-packages
setuptools: 40.8.0 from /usr/lib/python3/dist-packages
GStreamer: 1.14.4.0 from /usr/lib/python3/dist-packages/gi
Detailed information:
Python wrapper: python-gi 3.30.4
Relevant elements:
Found:
uridecodebin
souphttpsrc
appsrc
alsasink
osssink
oss4sink
pulsesink
id3demux
id3v2mux
lamemp3enc
mpegaudioparse
mpg123audiodec
vorbisdec
vorbisenc
vorbisparse
oggdemux
oggmux
oggparse
flacdec
flacparse
shout2send
Not found:
flump3dec
mad

What operating system are you using? If it’s Raspberry Pi OS, there’s a “Wait for network” option in raspi-config.

1 Like

Thank you so much!! That was really all it took.

1 Like

Another question: I’m using pulseaudio-dlna to stream from Mopidy to my speaker. Is there any way to make the speaker’s control buttons (play/pause etc.) work together with Mopidy?

If there isn’t one for DLNA, how can I do it with bluetooth?

Thanks!

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.