[Notice] open.spotify.com/get_access_token No longer works #1562
Replies: 75 comments 3 replies
-
That does suck. It was very useful for those projects that got screwed over by the recent API changes. Let's see if we can circumvent this check. It's always going to be cat and mouse with these guys. |
Beta Was this translation helpful? Give feedback.
-
I don't use this feature. But the error message "Invalid TOTP" makes me wonder whether it's failing for you because you were using MFA, and whether it was simply an auth failure lack of a "time based one time password" (TOTP)? |
Beta Was this translation helpful? Give feedback.
-
No, they've changed something on their end to prevent public access. It was previously a super easy way to get an access token with lots (full?) permissions. It only required you have a couple of browser cookies set (done for you when you login to Spotify.com). It was particularly useful since that included access to all the recently deprecated endpoints. They've now closed that loophole as part of their ongoing effort to lose as many customers as possible. I assume this endpoint is being used by their developer console, worth having a look there to see if we can undo this new protection. |
Beta Was this translation helpful? Give feedback.
-
This error also happened at Spotube, a custom Spotify player, and they found a solution. It seems Spotify changed how the token thingy works. Now, it is required to have a new request to get the final access token. From the current request, you have to create a totp with a timestamp given by Spotify and request this access_token to then use it on the new clienttoken api request. See:
Something similar like this would need to be implemented here in order to make Spotify integration work again. |
Beta Was this translation helpful? Give feedback.
-
Great! For the record, this is just one way to get an access token. We list 2 others on our wiki |
Beta Was this translation helpful? Give feedback.
-
As others have noticed in the related issues on other projects, Spotify is changing this a lot, when I first made this issue, it returned the error in my original post. Then SpotAPI cracked the TOTP: And we were able to get in and it gave this:
Then a few hours after that commit they openned it up completely and with nothing needed, no params, just like originally it would give this:
Though in my testing Python Requests didn't work code 429? Idk why but http.client worked. Now it looks like they've changed it once again, opening it with no params returns:
While SpotAPIs workaround still works the same, just wanted to document this here, it's very interesting to see what Spotify will decide on. |
Beta Was this translation helpful? Give feedback.
-
Welp, that note is something to take seriously. |
Beta Was this translation helpful? Give feedback.
-
Also, sometime between all that, (I'm assuming this is related, at least evidence of Spotify changing stuff) Spotify added TOTP login even for non MFA accounts on the web player, if you try logging in now, it'll send a code to your email, to login. It still gives a password login option though. |
Beta Was this translation helpful? Give feedback.
-
Thank god for y'all. Needed this badly to fix user search functionality in my app that became broke by their changes :) |
Beta Was this translation helpful? Give feedback.
-
Is there a link for it? |
Beta Was this translation helpful? Give feedback.
-
If you can't find it: https://github.com/librespot-org/librespot/wiki/Options#access-token |
Beta Was this translation helpful? Give feedback.
-
looks like Spotify switched over to HMAC-based One-Time Password for authentication in their latest web player
|
Beta Was this translation helpful? Give feedback.
-
@sam9116 I do not know how cryptography works. Does this mean we should hold any hope in being able to work around Spotify's new login process? Or should we give up? I really appreciate you checking into how their web player works, they broke my app and I'm in desperate need of a fix :-) |
Beta Was this translation helpful? Give feedback.
-
as far as I can see, the secrets are still being generated the same way. but you will need to implement a persistent counter that keeps track of how many times the OTP have been requested, since Spotify will keep track of that on their server, if the two numbers doesn't match => OTP incorrect => no token I'm not sure how sTime and cTime are generated or why they are needed as part of the token request, will have to do more testing around that |
Beta Was this translation helpful? Give feedback.
-
interesting, it looks like the counter is actually implemented on the client side |
Beta Was this translation helpful? Give feedback.
-
@kingosticks You're absolutely right, my apologies. This has derailed completely from the actual engineering challenge. |
Beta Was this translation helpful? Give feedback.
-
Thanks. I still think it's worth taking the ideas and facts here somewhere else. Github issues are really hard to navigate, especially when they get too long and older stuff gets hidden behind a load button. |
Beta Was this translation helpful? Give feedback.
-
For debugging newbies that would like to contribute, I draw attention to my last comment before the derailing, which will work as a manual method regardless of any additional future obfuscation. If they change algorithm away from TOTP, you can get relevant starting strings to search for, by setting XHR breakpoints for any network requests that seem like they are grabbing an access token. |
Beta Was this translation helpful? Give feedback.
-
@DiamondRoPlayz Yeah, but what's the code for retrieving this? |
Beta Was this translation helpful? Give feedback.
-
Added https://github.com/librespot-org/librespot/wiki/Reverse-engineering
I'm not holding my breath. Best bet is for as many people as possible to learn the reverse-engineering method. |
Beta Was this translation helpful? Give feedback.
-
But you really don't need to regex-grep the source (it's brittle and will break whenever Spotify tweaks their source code). It's actually much simpler: inject a runtime hook that captures every .secret assignment as the code executes. If you dump all of the objects with hooks in place, you'll see the secrets pop out already reconstructed, for example: "obj": {
"secret": "kQ19C]WQEC(]02.[^q)lMk\"",
"version": 12
} I wrote a Python script that does all the secrets extraction at runtime in the browser (via Playwright) - no source parsing required. The trick is to add a tiny setter before any Spotify code runs, so every PoC: spotify_monitor_secret_grabber.py, more info in the Debugging Tools section of the spotify_monitor project. Install playwright and run: pip install playwright
playwright install
python3 spotify_monitor_secret_grabber.py You'll get: ![]() |
Beta Was this translation helpful? Give feedback.
-
I just want to say a huge thank you for everyone involved in cracking spotify's auth process, you guys are giving those overpaid engineers a run for their money |
Beta Was this translation helpful? Give feedback.
-
@misiektoja Amazing work, I wanted to confirm that your runtime hook method works perfectly! It's a much more robust approach than parsing the source with regex. I was able to build on your idea and create a fully automated solution using GitHub Actions and JS to scrape the secrets on a schedule. I've open-sourced it here for anyone interested: https://github.com/Thereallo1026/spotify-secrets |
Beta Was this translation helpful? Give feedback.
-
To anyone who is using the JSON files in my repo, I have pushed an update that changes the format of secretBytes.json. It now uses a unified format with secrets.json. interface SpotifySecrets {
secret: string | number[];
version: number;
}
[]; |
Beta Was this translation helpful? Give feedback.
-
Well, when I was looking for materials to learn how to reverse engineer source code to find secrets but didn't know where to learn |
Beta Was this translation helpful? Give feedback.
-
@manhgdev Have a look at https://github.com/librespot-org/librespot/wiki/Reverse-engineering - practice on the current version until you can do it within 2-3 minutes, then you can do it again after the intern changes the object key from "secret" to "s3kr1t". |
Beta Was this translation helpful? Give feedback.
-
now this topic was a great read, thanks everybody! please, never close this! |
Beta Was this translation helpful? Give feedback.
-
Probably should turn it into a discussion? |
Beta Was this translation helpful? Give feedback.
-
Hey all. I've noticed that authenticating with the web player spdc token blocks me from using the official spotify web api calls. |
Beta Was this translation helpful? Give feedback.
-
Annnddd they changed how things work It's before the TOTP validity date, so I imagine they switched something up in their process. Damn. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Look for similar bugs
Please check if there's already an issue for your problem.
If you've only a "me too" comment to make, consider if a 👍 reaction
will suffice.
Description
A clear and concise description of what the problem is.
I don't know what Spotify changed but
open.spotify.com/get_access_token
no longer gives an accessToken, giving the errorVersion
What version(s) of librespot does this problem exist in?
All
How to reproduce
Steps to reproduce the behavior in librespot e.g.
Log
Error Spotify gives:
Host (what you are running
librespot
on):NA
Additional context
This really sucks for a lot of small OSS projects that depend on this for getting anonymous tokens aswell...
Beta Was this translation helpful? Give feedback.
All reactions