spotifyd icon indicating copy to clipboard operation
spotifyd copied to clipboard

Authentication failure when using pass and run spotiyd as service

Open dsolay opened this issue 5 years ago • 3 comments

Description Authentication fails when service starts

To Reproduce

  1. I added password_cmd = "pass show spotify.com/my_user | head -n 1" to config file.

  2. Create the following service and save it in ~/.config/systemd/user

       [Unit]
       Description=A spotify playing daemon
       Documentation=https://github.com/Spotifyd/spotifyd
       Wants=sound.target
       After=sound.target 
       Wants=network-online.target
       After=network-online.target
    
       [Service]
       ExecStart=/usr/bin/spotifyd --no-daemon
       Restart=always
       RestartSec=12
    
       [Install]
       WantedBy=default.target
    
  3. Run systemctl --user start spotifyd

Expected behavior when I start the service it asks me for my password to unlock my password store and then print the password in stdout.

Logs

Click to show logs
Oct 22 17:14:57 spotifyd[120234]: Loading config from "/home/ernest/.config/spotifyd/spotifyd.conf"
Oct 22 17:14:57 systemd[483]: Started A spotify playing daemon.
Oct 22 17:14:57 systemd[483]: Stopped A spotify playing daemon.
Oct 22 17:14:57 systemd[483]: spotifyd.service: Scheduled restart job, restart counter is at 122.
Oct 22 17:14:45 systemd[483]: spotifyd.service: Failed with result 'exit-code'.
Oct 22 17:14:45 systemd[483]: spotifyd.service: Main process exited, code=exited, status=101/n/a
Oct 22 17:14:45 spotifyd[119537]: Caught panic with message: Authentication failed with reason: BadCredentials
Oct 22 17:14:44 spotifyd[119537]: Connecting to AP "guc3-accesspoint-b-1m34.ap.spotify.com:443"
Oct 22 17:14:44 spotifyd[119537]: Using alsa volume controller.
Oct 22 17:14:44 spotifyd[119537]: No proxy specified
Oct 22 17:14:44 spotifyd[119537]: Running "pass show spotify.com/solay | head -n 1" using "/bin/bash"
Oct 22 17:14:44 spotifyd[119537]: No password specified. Checking password_cmd

Versions

  • OS: Arch Linux with kernel 5.9.1
  • Spotifyd: 0.2.24
  • cargo: 1.47.0

Additional context If I run directly spotifyd --no-daemon it works as expected

dsolay avatar Oct 23 '20 00:10 dsolay

Have exactly the same issue, also on Arch (installed with yay, started and enabled with systemctl --user)

  • OS: Arch Linux x86_64
  • Kernel: 5.9.1-arch1-1
  • WM: bspwm
  • spotifyd 0.2.24
  • spotify-tui 0.22.0

With spotifyd --verbose it works fine as well.

I guess it is similar to #576

baron-digit avatar Oct 24 '20 18:10 baron-digit

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jan 22 '21 18:01 stale[bot]

i do think this is still an issue, reopening

robinvd avatar Feb 08 '21 10:02 robinvd

Still an issue for me and would be good to fix. Meanwhile I have implemented a workaround which I'll add here in case it helps anyone in the interim.

Instead of launching as a systemd service, whenever I'll need spotifyd I create a bash alias that checks if spotifyd is currently running, and if not gets you to put your password in and directs it to /dev/null. I have a 5 second cache on gpg (set default-cache-ttl 5 in ~/.gnupg/gpg-agent.conf) so that when password_cmd = "pass show spotify.com/my_user | head -n 1" is called from spotifyd it works.

Example alias in ~/.bashrc for launching spotify-tui (spt) from the command line with command spotify:

# launch spotify-tui with spotifyd (if not already running)
spotify() {
    if ! pgrep -c "spotifyd" > /dev/null
    then
      echo "starting spotifyd..."
      pass show spotify.com/my_user >/dev/null
      spotifyd
    fi

    spt
}

jatkinson1000 avatar Dec 11 '22 15:12 jatkinson1000

Thank you for sharing your workaround!

I don't think this issue is related to spotifyd, but rather a systemd configuration problem with user services having no access to the graphical session and thus failing to display a password prompt.

It's working for me (as in: a GPG password prompt appears after login) with the following service definition:

[Unit]
Description=spotifyd test service
After=graphical-session.target

[Service]
Type=simple
ExecStart=/home/user/.local/share/cargo/bin/spotifyd --no-daemon --password-cmd "pass show spotify.com/username"

[Install]
WantedBy=graphical-session.target

(Desktop: GNOME)

You might have to adapt it to your specific setup, but that should give you the idea.

eladyn avatar Dec 11 '22 17:12 eladyn