spotifyd
spotifyd copied to clipboard
"Bad credentials" error when starting spotifyd
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 https://github.com/Spotifyd/spotifyd/issues/1269, but neither have worked.
To Reproduce
- 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
- [x] 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
Got exactly the same bug just today (been working for so long now)
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.
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.
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:
- Upstream report: https://github.com/librespot-org/librespot/issues/1308
- https://github.com/librespot-org/librespot-java/issues/921
- https://github.com/kokarare1212/librespot-python/issues/277
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" ?
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).
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.
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?
It might be some firewall issue? Make sure you expose the ports 5353 UDP and the one that the logs say via TCP.
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
usernameandpassword, as well ascache_pathandcache_directory. When I launchspotifyd, it saysZeroconf 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.
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.
FYI, as I mentioned on the librespot issue,
SpConnectionLoginZeroConfis 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?
@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.
@casualNavigator in my case the credentials.json are stored in the cache_path location specified in config file ~/.config/spotifyd/spotifyd.conf
Same issue on my end but I'm using raspotify.
@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.
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 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.
Discovery mode worked for me after I commented 'username' and 'password' out of the config file.
Discovery works, but then plays via my phone not desktop via spotify-qt.
user / password are still not working since yesterday.
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.
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.
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.
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 ".
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
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?
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 .
@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.
Just wanted to add here #1285 that if you have 2 IP address on your interface you may have issues with discovery.
Good catch. I'm going to try and fix that in my utility right now, because it stems from the default librespot behaviour. Unexpected for sure.
Edit: Okay, after three hours of mucking around, I think it's possibly a bug in either mdns, systemd, or I'm not understanding this enough to guess. Am giving up for now but the credentials one receives from zeroconf are long-lasting at least, if it's really a big problem I'd suggest raising it with librespot, because they added a command line option that I also adopted but had the same issue, so I'm not sure it actually got fixed.