mirror of
https://github.com/kokarare1212/librespot-python.git
synced 2026-04-25 00:25:49 +03:00
[GH-ISSUE #277] [BUG] BadCredentials #51
Labels
No labels
bug
dependencies
duplicate
enhancement
invalid
pull-request
question
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/librespot-python-kokarare1212#51
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @hazycora on GitHub (Jul 26, 2024).
Original GitHub issue: https://github.com/kokarare1212/librespot-python/issues/277
Describe the bug
Login fails on some accounts on some devices. My current guess is they're doing some kind of A/B test to phase out something this relies on? Maybe the protocol version needs to be updated?
Occurs not just here but also on the separate librespot-js project and librespot-java. The bug is not with some library-specific logic but with a change to Spotify- a fix here will likely also be able to be applied everywhere else.
To Reproduce
Expected behavior
The login should be successful.
Screenshots
Client Information (please complete the following information):
3b46fe560a)@hazycora commented on GitHub (Jul 26, 2024):
If it can't be reproduced, I have a server that has this problem, and I'm up for helping in any way I can!
@kokarare1212 commented on GitHub (Jul 27, 2024):
I don't know the details, I suspect that your IP address has been blacklisted due to the number of login attempts?
@hazycora commented on GitHub (Jul 28, 2024):
given that this occurred the only time I had ever tried on this server, no I don't believe that
@shayanmaher commented on GitHub (Jul 28, 2024):
also i have this issue for login auth with this error
raise Session.SpotifyAuthenticationException(ap_login_failed) librespot.core.Session.SpotifyAuthenticationException: BadCredentials@pdtan commented on GitHub (Jul 29, 2024):
I also got this error sometimes
@shayanmaher commented on GitHub (Jul 29, 2024):
i solve this problem it belongs to ip of datacenters which in blacklist popular Datacenters like hetzener,...etc has this problem you can solve this issue by use a fresh ip
@staniel359 commented on GitHub (Jul 29, 2024):
@kokarare1212 I've started to encounter this too.
@IVIanuu commented on GitHub (Jul 29, 2024):
I also encounter this issue since today.. Any fix?
@phuketbinaryt commented on GitHub (Jul 29, 2024):
Same issue here with the bad credentials.
@dylenthomas commented on GitHub (Jul 29, 2024):
This just started happening to me today too, might be an issue with spotify's client? I tried on a MacBook with latest MacOS and my linux desktop, both having same issue. I also tried with the latest install of librespot, that was working yesterday.
Since this is happening to so many people they might have an issue with their api right now?
@clemwo commented on GitHub (Jul 29, 2024):
I also have this issue on a windows machine.
It's also being discussed in the librespot project directly here : https://github.com/librespot-org/librespot/issues/1308
Feels like spotify changed something on their end maybe?
@rgon commented on GitHub (Jul 30, 2024):
@shayanmaher happening to me on a residential IP. Definitely not data center blacklisting, but rather seems like a buggy rolled-out deploy in their end or rather some of their pesky A/B API testing
@hazycora commented on GitHub (Aug 2, 2024):
this is not true. happens on all residential IPs ive tried now. that was absolutely just part of the rollout.
@TreeOfSelf commented on GitHub (Aug 2, 2024):
Happening to me as well.
@kokarare1212 commented on GitHub (Aug 3, 2024):
It appears that login using username and password has been discontinued.
https://github.com/librespot-org/librespot-java/issues/921#issuecomment-2258440907
Please use other login methods (e.g. zeroconf) or PR a new login method instead.
@staniel359 commented on GitHub (Aug 3, 2024):
@kokarare1212 Could you then provide the instructions on how to use Zeroconf instead of Session?
@realCmdData commented on GitHub (Aug 7, 2024):
Same issue for me, even changing IP's through a VPN doesn't work.
@realCmdData commented on GitHub (Aug 7, 2024):
UPDATE:
Got it to work... Somehow... Still not quite sure how but I tried restarting my PC and deactivating my VPN, and it worked. Perhaps through trial and error? Or Spotify is blocking CLI requests that come from known VPN servers? I have no idea...
@pdtan commented on GitHub (Aug 8, 2024):
Please provide the instructions on how to use Zeroconf instead of Session?
@kokarare1212 commented on GitHub (Aug 8, 2024):
It is incomplete but should work.
See the original librespot-java for details.
Sample code can be found here.
Sessions within zeroconf should be accessible via these:
zeroconf._ZeroconfServer__sessionRemember I have very little time to devote to these projects.
@pdtan commented on GitHub (Aug 8, 2024):
Very unclear. btw, I don't see
_ZeroconfServer__session:@kingosticks commented on GitHub (Aug 12, 2024):
Forgive me for jumping in, but you have to actually use the zeroconf server to auth a client before a session will be created. Given the log you provided, it doesn't look like you did that.
@dracarys69 commented on GitHub (Aug 15, 2024):
idk about you guys i can still login fine with email and password and whenever i get BadCredentials issue i delete the credentials json and change my account password and it starts working again. tho its been a while since i had that issue
@g42ftw commented on GitHub (Aug 15, 2024):
Login with username/password via
.user_pass()method is no longer possible: https://github.com/librespot-org/librespot/issues/1308#issuecomment-2276196094@pdtan you may use this very sketchy code to generate credentials file to use further. Notice that device running the script should be on the same network as a desktop client in order to transfer playback or/and grab session
Use
.stored_file()method instead or.user_pass()on session builder stage to load login credentials from local file:It should use
credentials.jsonfrom current working directory by default.@clemwo commented on GitHub (Aug 15, 2024):
Cool beans, that works.
Question: do the credentials expire?
I want to run librespot in a docker container and maybe transfering playback once would be fine.
But if the token expired every few days that would be an issue for me.
@kingosticks commented on GitHub (Aug 15, 2024):
Reusable credentials do not expire.
@g42ftw commented on GitHub (Aug 15, 2024):
@clemwo they don't expire, unless you change your password or Spotify does. Successful login with zeroconf should always return the same long-live credentials that
.user_passalways did (username+credentials blob).The Spotify desktop client stores account login data in the client configuration file in a similar way:
.config/Spotify/prefs
@pdtan commented on GitHub (Aug 16, 2024):
@clemwo thanks, but I use credentials.json from start, sometimes BadCredentials still happended, not usual. If using zeroconf to only create credentials.json, I actually don't need it.
@sertraline commented on GitHub (Aug 17, 2024):
On Windows (this works on Linux) trying to use zeroconf results in the following:
@direct-dok commented on GitHub (Aug 22, 2024):
Hello everyone. Tell me if the librespot.core problem has been
solved.Session.SpotifyAuthenticationException: BadCredentialsCan someone tell me what needs to be done? Thanks for any hints
@sertraline commented on GitHub (Aug 26, 2024):
I don't quite get how to generate the credentials. Quick glance at zeroconf.py tells me that I somehow need to get into
handle_add_userto generate the credentials. I have tried to reopen the spotify client, log out and log in back but the add_user request just never happens, so I'm clueless on how to actually use it.@kingosticks commented on GitHub (Aug 26, 2024):
Select the running librespot instance in your Spotify client. You should find it in the list of Spotify Connect devices in Spotify's client. That device menu is at the bottom of their app on the currently playing bar, it has a speaker/computer icon.
Selecting the librespot instance will send the required auth data to the Zeroconf server where it can be stored and reused indefinitely.
@clemwo commented on GitHub (Sep 15, 2024):
Unfortunately this code doesn't work when run in asyncio.
I get the following error:
Does anyone have an idea on how to adjust the code to make it run in async?
@shuttie commented on GitHub (Sep 16, 2024):
This tool helped me to generate the
credentials.json: https://github.com/dspearson/librespot-auth@greffgreff commented on GitHub (Nov 22, 2024):
I can confirm that username and password is still possible with mobile authentication shenanigans. I am to get an access token and interact with spotify's api with
librespot-js: https://git.gay/h/librespot-js/src/branch/main/src/login5.ts@jakiepari commented on GitHub (Dec 20, 2024):
i'm using that tool and finally grabbed the credentials.json. but i try with this my code
its always giving: Error creating session: You must select an authentication method. how to use credentials.json? thank you :D
@moejoe95 commented on GitHub (Dec 26, 2024):
Got the same error. Looks like the credential file has changed its format. In the source code it is expected that the json contains
type,username,credentials, see here. However, in the file i got from librespot-auth the fields are namedauth_typeandauth_data. Renaming the fields in the file fixed the issue for me.@jakiepari commented on GitHub (Dec 27, 2024):
I'm trying to rename it. but what should i fill in the type? :D btw thank you for this solution
@moejoe95 commented on GitHub (Dec 27, 2024):
Should be a Enum value as defined here. I used
AUTHENTICATION_STORED_SPOTIFY_CREDENTIALS.@jakiepari commented on GitHub (Dec 27, 2024):
for example i try with this format: {"type":1,"username":"numberi","credentials":"string"}. and i try to use enum value defined 1 and its giving error: Error: Enum AuthenticationType has no value defined for name 1. how to use the value?
@moejoe95 commented on GitHub (Dec 27, 2024):
use it like this:
"type":"AUTHENTICATION_STORED_SPOTIFY_CREDENTIALS"@jakiepari commented on GitHub (Dec 27, 2024):
this is worked! Thank you very much!
@root4loot commented on GitHub (Sep 30, 2025):
Same issue with username/password auth. As a workaround, I got it to work with OAuth credentials from Rust librespot.
See pull #314 which adds support for this in stored_file().