Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Bad credentials" error when starting spotifyd #1293

Open
1 of 6 tasks
DavidHospital opened this issue Jul 29, 2024 · 86 comments · May be fixed by #1321
Open
1 of 6 tasks

"Bad credentials" error when starting spotifyd #1293

DavidHospital opened this issue Jul 29, 2024 · 86 comments · May be fixed by #1321
Labels
bug A functionality or parts of a program that do not work as intended

Comments

@DavidHospital
Copy link

Description
I've been using spotifyd for a few years now without issue. Just this morning when trying to connect, I got the following error:

failed to connect to spotify: Login failed with reason: Bad credentials

I am able to login just fine on all my other devices, it's only using spotifyd where I have this issue. I have also tried restarting my PC, and using my email as username instead of the username string, as suggested by #1269, but neither have worked.

To Reproduce

  1. start with spotifyd --verbose --no-daemon

Expected behavior
spotifyd should authenticate with spotify

Logs

Click to show logs
<!-- PLEASE PASTE YOUR LOGS BELOW THIS LINE WHEN REPORTING BUGS. Make sure to run spotifyd using the `--verbose` flag -->
<!-- They have to be betwenn the `/summary` and the `/details` HTML tags, and inside the backticks '`' -->  
Loading config from "/home/dhospital/.config/spotifyd/spotifyd.conf"
CliConfig { config_path: None, no_daemon: true, verbose: true, pid: None, shared_config: SharedConfigValues { username: Some("taken out for privacy"), username_cmd: None, password: Some("taken out for privacy"), password_cmd: None, use_keyring: false, use_mpris: None, dbus_type: None, on_song_change_hook: None, cache_path: None, no-audio-cache: false, backend: Some(Alsa), volume_controller: None, device: None, control: None, mixer: None, device_name: Some("WorkUbuntu"), bitrate: Some(Bitrate160), audio_format: None, initial_volume: Some("50"), volume_normalisation: false, normalisation_pregain: Some(-10.0), zeroconf_port: None, proxy: None, device_type: Some(Computer), autoplay: false, max_cache_size: None } }
Found user shell: Some("/bin/bash")
No proxy specified
registering event source with poller: token=Token(2147483649), interests=READABLE
Using software volume controller.
registering event source with poller: token=Token(0), interests=READABLE | WRITABLE
signal: Want
signal found waiting giver, notifying
poll_want: taker wants!
signal: Want
signal: Want
Ignoring blacklisted access point ap-gue1.spotify.com:4070
Ignoring blacklisted access point ap-gue1.spotify.com:443
Ignoring blacklisted access point ap-gue1.spotify.com:80
Connecting to AP "ap-gae2.spotify.com:443"
deregistering event source from poller
signal: Closed
registering event source with poller: token=Token(16777216), interests=READABLE | WRITABLE
deregistering event source from poller
failed to connect to spotify: Login failed with reason: Bad credentials

Compilation flags

  • dbus_mpris
  • dbus_keyring
  • alsa_backend
  • portaudio_backend
  • pulseaudio_backend
  • rodio_backend

Versions (please complete the following information):

  • OS: Ubuntu 22.04.4 LTS
  • Spotifyd: 0.3.5 (cargo)
  • cargo: 1.79.0
@DavidHospital DavidHospital added the bug A functionality or parts of a program that do not work as intended label Jul 29, 2024
@mghalix
Copy link

mghalix commented Jul 29, 2024

Got exactly the same bug just today (been working for so long now)
image

@robbertkauffman
Copy link

Same here. It was working fine for months and stopped working this morning. Using configured username & password and have disabled zeroconf.

I believe it's an issue with librespot as I get the same error with Raspotify.

@timjrd
Copy link

timjrd commented Jul 29, 2024

Hi! 🙂 Same thing, but I run librespot directly like that:

#!/usr/bin/env bash
librespot \
    --username "$(head -n 1 ~/.config/librespot/auth)" \
    --password "$(tail -n 1 ~/.config/librespot/auth)" \
    --backend alsa \
    --format F32 \
    --mixer softvol \
    --volume-ctrl fixed \
    --initial-volume 100 \
    --bitrate 320

... then I get:

[2024-07-29T14:52:58Z ERROR librespot] Connection failed: Login failed with reason: Bad credentials

Nothing interesting with the verbose flag.

@eladyn
Copy link
Member

eladyn commented Jul 29, 2024

Indeed something seems to have changed on the Spotify side, since I found already several reports (on several projects) which report the exact same error (most reports have been published recently). It started happening for me too, the issue persists when using the newest librespot dev version, so probably something that needs to be fixed upstream.

Anyway, for now what still should be working (from my tests) is discovery, so until this is fixed it might be a viable option for you?


Issues in other projects:

@inkhey
Copy link

inkhey commented Jul 30, 2024

Hello all, same problem here too.

Anyway, for now what still should be working (from my tests) is discovery, so until this is fixed it might be a viable option for you?

What do you mean by "discovery" ?

@dabalroman
Copy link

dabalroman commented Jul 30, 2024

What do you mean by "discovery" ?

Indeed, it still works with discovery.
To enable it, all of these values in config should be commented out.

#username=
#password=

See here: https://docs.spotifyd.rs/config/File.html#alternatives-to-storing-your-password-in-the-config-file

Your device will be visible in spotify app as a player (probably requires same network for devices to work).

@eladyn
Copy link
Member

eladyn commented Jul 30, 2024

Yeah, thanks for the clarification. For spotifyd, you need to comment out the username and password line in the config to make it go into discovery mode.

@DavidHospital
Copy link
Author

See here: https://docs.spotifyd.rs/config/File.html#alternatives-to-storing-your-password-in-the-config-file

Your device will be visible in spotify app as a player (probably requires same network for devices to work).

I can't get this to work, I've commented out username and password, as well as cache_path and cache_directory. When I launch spotifyd, it says Zeroconf server listening on 0.0.0.0:39127, but none of my devices can see it on the network. Am I missing something?

@eladyn
Copy link
Member

eladyn commented Jul 30, 2024

It might be some firewall issue? Make sure you expose the ports 5353 UDP and the one that the logs say via TCP.

@bennylb
Copy link

bennylb commented Jul 31, 2024

See here: https://docs.spotifyd.rs/config/File.html#alternatives-to-storing-your-password-in-the-config-file
Your device will be visible in spotify app as a player (probably requires same network for devices to work).

I can't get this to work, I've commented out username and password, as well as cache_path and cache_directory. When I launch spotifyd, it says Zeroconf server listening on 0.0.0.0:39127, but none of my devices can see it on the network. Am I missing something?

I had to use the official Spotify client to first authenticate with zeroconf and then spotifyd became visible to other devices on the network. Just opening the official app was enough.

@dspearson
Copy link

FYI, as I mentioned on the librespot issue, SpConnectionLoginZeroConf is a mandatory implementation feature for Spotify Connect devices and the documentation for hardware implementers states that SpConnectionLoginPassword was to only be used for testing purposes -- it has in fact been removed from the eSDK and therefore I assume should never be used.

The blob obtained via ZeroConf authentication flow is not tied to devices on the same network currently, and so for those wishing to reduce effort or network/mDNS config issues, simply running spotifyd on the same machine as a running official client for initial device registration, and then copying the credentials obtained to a remote machine where spotifyd is to be deployed, should work just fine. At least I tested it with librespot with no issues.

@casualNavigator
Copy link

FYI, as I mentioned on the librespot issue, SpConnectionLoginZeroConf is a mandatory implementation feature for Spotify Connect devices and the documentation for hardware implementers states that SpConnectionLoginPassword was to only be used for testing purposes -- it has in fact been removed from the eSDK and therefore I assume should never be used.

The blob obtained via ZeroConf authentication flow is not tied to devices on the same network currently, and so for those wishing to reduce effort or network/mDNS config issues, simply running spotifyd on the same machine as a running official client for initial device registration, and then copying the credentials obtained to a remote machine where spotifyd is to be deployed, should work just fine. At least I tested it with librespot with no issues.

@dspearson thanks for this, this explained why spotifyd suddenly stoped working today because of Bad Credential errors (?)

I cannot find the blob ~/.cache/spotifyd nor ~/.config/spotifyd, is it stored here?

@dspearson
Copy link

@casualNavigator unfortunately I'm not a spotifyd user but taking a brief look at the code it uses librespot's crates directly so maybe try find on ~, looking for credentials.json? You're typically looking for a key called auth_data.

@casio1983
Copy link

@casualNavigator in my case the credentials.json are stored in the cache_path location specified in config file ~/.config/spotifyd/spotifyd.conf

@mazarian
Copy link

Same issue on my end but I'm using raspotify.

@casualNavigator
Copy link

@dspearson and @casio1983 Thanks, found a credentials.json file for spotify_player cli (which uses librespot) in ~/.config/spotify-player/credentials.json, and indeed contained auth_data but I wasn't able to use it, as I tried resetting my Spotify password trying to troubleshoot this issue. Thanks for pointing out to the right direction.

I've tried to generate the auth_data manually using instructions here https://developer.spotify.com/documentation/web-api/tutorials/getting-started:

curl -X POST "https://accounts.spotify.com/api/token" \
     -H "Content-Type: application/x-www-form-urlencoded" \
     -d "grant_type=client_credentials&client_id=my-client-id&client_secret=my-client-secret"

And updated the auth_data value in the credentials.json file, unfortunately that didn't work.

@Semmu
Copy link

Semmu commented Aug 14, 2024

same issue here, and also i got an email from Spotify forcing me to change my password because they detected some "suspicious activity".

(i really hope they are not killing spotifyd and other third-party clients...)

@dabalroman
Copy link

same issue here, and also i got an email from Spotify forcing me to change my password because they detected some "suspicious activity".

(i really hope they are not killing spotifyd and other third-party clients...)

Same here. Just migrated from raspotify to spotifyd and got that email. At least zeroconf works better in spotifyd.

@elliotclee
Copy link

Discovery mode worked for me after I commented 'username' and 'password' out of the config file.

@whisperzer0
Copy link

Discovery works, but then plays via my phone not desktop via spotify-qt.

user / password are still not working since yesterday.

@Semmu
Copy link

Semmu commented Aug 15, 2024

is there a workaround to authenticate with some saved credentials/token automatically? could spotifyd write some tokens to some file after a successful zeroconf authentication, which it could read at startup?

the reason im asking is because my spotifyd disconnects after being idle for hours ( bugreported here #903 ) for which my workaround is to monitor/poll my active devices via the API and restart the spotifyd container whenever the API thinks its gone. ( commented here )

but since the username+password auth has been turned off on Spotify's side, whenever my container is restarted it wont belong to my account, so it will essentially get in a "bootloop" and i will need to do the zeroconf authentication each time (which is inconvenient). it would be nice if spotifyd persisted the tokens in some file which could be re-used until they are expired.

@dabalroman
Copy link

There is a file called credentials.json in cache directory. There is some kind of key inside alongside username. Check if that directory is not wiped out on docker down action. It works for at least couple of hours and it's visible in spotify app after device restart. I compiled Spotifyd from source, it's running a system service under Ubuntu.

@dspearson
Copy link

You can use the cached discovery credentials for a long time. I've used mine for weeks now. Like previously mentioned, just make sure they're not deleted in your workflow.

@jolo2486
Copy link

jolo2486 commented Aug 16, 2024

Same or similar problem here with spotifyd 0.3.5 on Ubuntu 22.04.4:

$ spotifyd --no-daemon --verbose --username redacted --password redacted --backend pulseaudio --debug-credentials

No config file specified. Running with default values
CliConfig { config_path: None, no_daemon: true, verbose: true, pid: None, shared_config: SharedConfigValues { username: Some(redacted), username_cmd: None, password: Some(redacted), password_cmd: None, use_keyring: false, use_mpris: None, dbus_type: None, on_song_change_hook: None, cache_path: None, no-audio-cache: false, backend: Some(PulseAudio), volume_controller: None, device: None, control: None, mixer: None, device_name: None, bitrate: None, audio_format: None, initial_volume: None, volume_normalisation: false, normalisation_pregain: None, zeroconf_port: None, proxy: None, device_type: None, autoplay: false, max_cache_size: None } }
Found user shell: Some("/bin/bash")
No proxy specified
Using software volume controller.
Ignoring blacklisted access point ap-gew4.spotify.com:4070
Ignoring blacklisted access point ap-gew4.spotify.com:443
Ignoring blacklisted access point ap-gew4.spotify.com:80
Ignoring blacklisted access point ap-gue1.spotify.com:443
Failed to resolve Access Point: Unable to resolve any viable access points.
Using fallback "ap.spotify.com:443"
Connecting to AP "ap.spotify.com:443"
failed to connect to spotify: Login failed with reason: Bad credentials

I also tried discovery mode by commenting out username and password in spotifyd.conf, but it seems to be stuck. I don't think I have a credentials.json anywhere because I've not used spotifyd on this computer before, only at work, where it worked fine (haven't tried these past weeks):

Additional question. Do I need a credentials.json for discovery to work and can I create one myself?

$ spotifyd --no-daemon --verbose

Loading config from "/home/mrredacted/.config/spotifyd/spotifyd.conf"
CliConfig { config_path: None, no_daemon: true, verbose: true, pid: None, shared_config: SharedConfigValues { username: None, username_cmd: None, password: None, password_cmd: None, use_keyring: false, use_mpris: None, dbus_type: None, on_song_change_hook: Some("command_to_run_on_playback_events"), cache_path: Some("cache_directory"), no-audio-cache: true, backend: Some(Alsa), volume_controller: Some(Alsa), device: Some("alsa_audio_device"), control: Some("alsa_audio_device"), mixer: Some("PCM"), device_name: Some("redacted"), bitrate: Some(Bitrate160), audio_format: Some(S16), initial_volume: Some("90"), volume_normalisation: true, normalisation_pregain: Some(-10.0), zeroconf_port: Some(1234), proxy: None, device_type: Some(Speaker), autoplay: true, max_cache_size: Some(1000000000) } }
Found user shell: Some("/bin/bash")
No username specified. Checking username_cmd
No username_cmd specified
No password specified. Checking password_cmd
No password_cmd specified
No proxy specified
Using alsa volume controller.
no usable credentials found, enabling discovery
Using device id 'a35baa7bd3fe13630f66325b0b734cfc0c7cdeec'
Zeroconf server listening on 0.0.0.0:1234
found interface Interface { name: "eno1", addr: V4(Ifv4Addr { ip: 192.168.1.177, netmask: 255.255.255.0, broadcast: Some(192.168.1.255) }) }
sending packet to 224.0.0.251:5353
found interface Interface { name: "eno1", addr: V4(Ifv4Addr { ip: 192.168.1.177, netmask: 255.255.255.0, broadcast: Some(192.168.1.255) }) }
sending packet to [ff02::fb]:5353
received packet from 192.168.1.177:5353
received packet from 192.168.1.177:5353 with no query
received packet from 192.168.1.177:5353
received packet from 192.168.1.177:5353 with no query
received packet from [fe80::aeca:908d:27:dd69%2]:5353
received packet from [fe80::aeca:908d:27:dd69%2]:5353 with no query
received packet from [fe80::aeca:908d:27:dd69%2]:5353
received question: IN _ipps._tcp.local
received question: IN _ipp._tcp.local
received packet from 192.168.1.177:5353
received question: IN _ipps._tcp.local
received question: IN _ipp._tcp.local
_

and it just stays there (+10 min), nothing happens, and I have to interrupt the process.

I've n-ple (n>>2) checked the username and password as well as tried both with conf and CLI (-u, -p) with and without " and/or '. I also changed/updated my spotify password and it has no "problematic" characters such as spaces or ".

@dspearson
Copy link

dspearson commented Aug 16, 2024

For those that seem to have issues creating the credentials.json file, I have created the following: https://github.com/dspearson/librespot-auth

Build with cargo build --release (requires rust compiler/toolkit, see https://rustup.rs/). Example usage:

❯ ./target/release/librespot-auth --name "Example Speaker"
Open Spotify and select output device: Example Speaker
Credentials saved: credentials.json

@Mike-de-bike
Copy link

For those that seem to have issues creating the credentials.json file, I have created the following: https://github.com/dspearson/librespot-auth

Build with cargo build --release (requires rust compiler/toolkit, see https://rustup.rs/). Example usage:

❯ ./target/release/librespot-auth --name "Example Speaker"
Open Spotify and select output device: Example Speaker
Credentials saved: credentials.json

is that using of a manually created credentials.json a workaround to get spotifyd in zeroconf mode running? Has someone positive results in using it?

@MarekLew
Copy link

For those that seem to have issues creating the credentials.json file, I have created the following: https://github.com/dspearson/librespot-auth

Build with cargo build --release (requires rust compiler/toolkit, see https://rustup.rs/). Example usage:

❯ ./target/release/librespot-auth --name "Example Speaker"
Open Spotify and select output device: Example Speaker
Credentials saved: credentials.json

It works. After confirming authorization for "Example Speaker" in the spotify client, copy the generated credentials.json file to the cache_patch location saved in the ~/.config/spotifyd/spotifyd.conf file, e.g. ~/.cache/spotifyd .

@casualNavigator
Copy link

@dspearson Worked, flawlessly! Built it in Rust to too, what an absolute Chadman!

@Mike-de-bike Confirmed working, was able to use spotifyd and spotify-player again.

@trames57
Copy link

Just wanted to add here #1285 that if you have 2 IP address on your interface you may have issues with discovery.

@ivoshm
Copy link

ivoshm commented Sep 29, 2024

anyone know any alternatives that download natively from spotify and actually work since the removed password auth?

I'm afraid the only way to finally solve this problem in spotifyd is to switch to OAuth authentication (as librespot already did in dev branch).

@makzef
Copy link

makzef commented Oct 9, 2024

For those that seem to have issues creating the credentials.json file, I have created the following: https://github.com/dspearson/librespot-auth

Build with cargo build --release (requires rust compiler/toolkit, see https://rustup.rs/). Example usage:

❯ ./target/release/librespot-auth --name "Example Speaker"
Open Spotify and select output device: Example Speaker
Credentials saved: credentials.json

Nope, not working. Tried to use provided librespot package, tried build it myself. Spotify app doesn't see any devices, through it only shows other devices with official clients.

@makzef
Copy link

makzef commented Oct 9, 2024

For those that seem to have issues creating the credentials.json file, I have created the following: https://github.com/dspearson/librespot-auth
Build with cargo build --release (requires rust compiler/toolkit, see https://rustup.rs/). Example usage:

❯ ./target/release/librespot-auth --name "Example Speaker"
Open Spotify and select output device: Example Speaker
Credentials saved: credentials.json

Nope, not working. Tried to use provided librespot package, tried build it myself. Spotify app doesn't see any devices, through it only shows other devices with official clients.

After some time, I remembered that similar issues were due to the firewall. And this was mentioned above. I didn't know which port librespot-auth uses, or is it require something else. So, I just stopped firewalld.service temporarily and spotify client finaly showed a new device. Then I managed to generate credentials.json.

So anyone having problems with missing devices in spotify client, better check firewall setting.

Thank you.

@Jorpy76
Copy link

Jorpy76 commented Oct 11, 2024

Hello, thank you! I followed the steps, and it finally started working again.

@hadronized
Copy link

hadronized commented Oct 16, 2024

I don’t have a native Spotify client, and going through the Web browser doesn’t see the output device. I feel I’m stuck. :(

EDIT: nevermind, I was able to do it with the phone as I’m on the same network.

@fgordilloz
Copy link

I don’t have a native Spotify client, and going through the Web browser doesn’t see the output device. I feel I’m stuck. :(

EDIT: nevermind, I was able to do it with the phone as I’m on the same network.

image

From Spotify Web Player you can view devices

@hadronized
Copy link

I don’t have a native Spotify client, and going through the Web browser doesn’t see the output device. I feel I’m stuck. :(
EDIT: nevermind, I was able to do it with the phone as I’m on the same network.

image

From Spotify Web Player you can view devices

I know, and it wasn’t showing up there; I really had to go through my phone to get it. I’m not sure why, at least it worked. :)

@0323pin
Copy link

0323pin commented Oct 17, 2024

FWIW, librespot-0.5.0 was released yesterday and this is fixed.

@gbwebdev
Copy link

gbwebdev commented Oct 20, 2024

FWIW, librespot-0.5.0 was released yesterday and this is fixed.

I simply tried to rebuild spotifyd after changing the "0.4" to "0.5" for librespot dependencies in the Cargo.toml (hey, it was worth a shot), but it does not work...
I get multiple errors such as :

error[E0308]: mismatched types
   --> src/setup.rs:158:38
    |
158 |         if username.as_ref() == Some(&credentials.username) {
    |                                 ---- ^^^^^^^^^^^^^^^^^^^^^ expected `&String`, found `&Option<String>`
    |                                 |
    |                                 arguments to this enum variant are incorrect
    |
    = note: expected reference `&std::string::String`
               found reference `&std::option::Option<std::string::String>`

Which to me sounds like we're on the right track.
I am not surprised of course (that a simple "search & replace" don't do the job), but it means that librespot does not use semantic versioning :/ ...

Meanwhile, I'm affraid the solution won't come from me : I never wrote a single line of Rust and I gave pretty much everything I got on this "search and replace" in the Cargo.toml ;-)

@eladyn
Copy link
Member

eladyn commented Oct 21, 2024

Just a quick heads up: I'm basically done with bumping librespot to the new version, just some dbus MPRIS stuff is still missing, where I'm working on getting rid of the web API requests completely. I hope to get it done within the next couple of days, however if you'd like to help testing or can't wait (and don't need DBus for your setup), I published the current state here.
Also, OAuth is still not implemented in spotifyd, but it should be available soon.

@dataCobra
Copy link

Tried the branch you recommended but I sadly still get the "bad credentials" error.

@eladyn
Copy link
Member

eladyn commented Oct 23, 2024

Yes, the broken user-password auth is still the one used in that branch (the new OAuth way needs to be adapted from upstream first).

@GardenerGeralt
Copy link

Hi @eladyn thank you for working on this issue. When do you think the fixed version will come to Arch packages?

@eladyn
Copy link
Member

eladyn commented Oct 30, 2024

Usually, Arch should be quite fast, once we release the new version. But since that hasn't happened yet, it'll take a couple of days at least before that.

@poetex
Copy link

poetex commented Nov 16, 2024

Bumping this issue. I have tried everything in this thread and still cannot resolve the Bad Credentials error.

@citosid
Copy link

citosid commented Nov 21, 2024

I've never used it before so I don't have a credentials file, and I tried creating one but it does not like the format. Does anyone has an example of the shape of the json file?

@RazoBeckett
Copy link

I've never used it before so I don't have a credentials file, and I tried creating one but it does not like the format. Does anyone has an example of the shape of the json file?

{"username":"redacted","auth_type":1,"auth_data":"redacted"}

@RazoBeckett
Copy link

if someone have fixed this issue or solved it help me get it working please

@MiuKaShi
Copy link

MiuKaShi commented Dec 11, 2024

if someone have fixed this issue or solved it help me get it working please

Here, I found a simple way to solve this problem with https://github.com/aome510/spotify-player. Hope it helps.

  1. Install and open spotify-player, after finishing authentication, the credentials.json will be created in ~/.cache/spotify-player
  2. Set cache_path and username_cmd in spotifyd.conf as follows (replace user_name with your name)
cache_path = "/home/user_name/.cache/spotifyd"
username_cmd = "cp /home/user_name/.cache/spotify-player/credentials.json /home/user_name/.cache/spotifyd && jq -r .username /home/user_name/.cache/spotifyd/credentials.json"
# password = ""

Now, run spotifyd --no-daemon --verbose it should show that the authentication is successful. You can use spotify-player as a TUI player.

@kingofsquirrel
Copy link

kingofsquirrel commented Dec 19, 2024

I've also just encountered this issue and I tried to solve it by using zeroconf. So I basically just left my username and password field blank and to my understanding, the first client that connects basically passes on its saved credentials.

However, when I tried to connect to the device, the addon crashed and I got this error:

Connection failed: Cannot create session: Connection refused (os error 111)

I solved it by adding this line to /etc/hosts

0.0.0.0 apresolve.spotify.com

No idea if this helps anyone, just thought I'd mention it.

@CompeyDev
Copy link

CompeyDev commented Dec 19, 2024

if someone have fixed this issue or solved it help me get it working please

Here, I found a simple way to solve this problem with aome510/spotify-player. Hope it helps.

1. Install and open `spotify-player`, after finishing authentication, the `credentials.json ` will be created in  `~/.cache/spotify-player`

2. Set cache_path and username_cmd in spotifyd.conf as follows (replace user_name with your name)
cache_path = "/home/user_name/.cache/spotifyd"
username_cmd = "cp /home/user_name/.cache/spotify-player/credentials.json /home/user_name/.cache/spotifyd && jq -r .username /home/user_name/.cache/spotifyd/credentials.json"
# password = ""

Now, run spotifyd --no-daemon --verbose it should show that the authentication is successful. You can use spotify-player as a TUI player.

Heads up -- this misses a trailing / and hence copies it to a file.

- username_cmd = "cp /home/user_name/.cache/spotify-player/credentials.json /home/user_name/.cache/spotifyd && jq -r .username /home/user_name/.cache/spotifyd/credentials.json"
+ username_cmd = "cp /home/user_name/.cache/spotify-player/credentials.json /home/user_name/.cache/spotifyd/ && jq -r .username /home/user_name/.cache/spotifyd/credentials.json"

You would also need to create the ~/.cache/spotifyd directory first.

@CompeyDev
Copy link

Trying the workaround, I'm able to get quite far, however ultimately I'm getting this error:

Resolve access points error: Service unavailable { client error (Connect) }
Connecting to AP "ap.spotify.com:443"
unknown subscription uri=hm://pusher/v1/connections/REDACTED
response pushed over Mercury: MercuryResponse { uri: "hm://pusher/v1/connections/REDACTED", status_code: 200, payload: [] }
could not dispatch command: Service unavailable { error handling Mercury response: MercuryResponse { uri: "hm://pusher/v1/connections/REDACTED", status_code: 200, payload: [] } }
Authenticating with AP using AUTHENTICATION_STORED_SPOTIFY_CREDENTIALS
Authenticated as 'UID' !
failed to connect to spotify: Service unavailable { Session is not connected }

@Boxer66
Copy link

Boxer66 commented Dec 26, 2024

I also had some problems with this. Usually I use ncspot for my spotify needs but it doesn´t work properly atm so I had to install spotifyd.

I got it working with a combination of solutions provided here.
I use librespot 0.60 on a EndeavourOS laptop with i3-wm. I am a spotify premium user.

  1. Edit /etc/hosts and add this line
    0.0.0.0 apresolve.spotify.com

  2. Create the ~/.cache/spotifyd folder

  3. install and start spotify-player to create credentials.json

  4. Set cache_path and username_cmd in spotifyd.conf as follows (replace user_name with your name)

cache_path = "/home/user_name/.cache/spotifyd"
username_cmd = "cp /home/user_name/.cache/spotify-player/credentials.json /home/user_name/.cache/spotifyd/ && jq -r .username /home/user_name/.cache/spotifyd/credentials.json" and comment out password = ""

  1. run spotifyd --no-daemon --verbose
  2. You can now use spotify-player or in my case I use spotify-tui
  3. I also edited spotifyd.conf and commented out use-keyring and password_cmd

Thanks to MiuKaShi, kingofsquirrel and CompeyDev

2024-12-26-07_41_46-screenshot
2024-12-26-07_46_18-screenshot

@blur131
Copy link

blur131 commented Dec 26, 2024 via email

@eladyn
Copy link
Member

eladyn commented Dec 30, 2024

I finally got around to implementing OAuth support in spotifyd: #1321. It's become quite a large PR, so it's probably good to not merge it directly, but wait for some testing first. So if you've got the time to try the changes, that'd be very much appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A functionality or parts of a program that do not work as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.