-
Notifications
You must be signed in to change notification settings - Fork 1
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
TokenType authorization_code #3
Comments
I don't have any official Spotify hardware. So I did not have the chance to test this tool on a device sending If it is not the case, you can try to intercept the traffic between the official client and your receiver. Or you can create a false receiver and try to connect with the official client to get the information it is sending. It would help to develop another authentication mechanisms if needed. |
Yep, I'll give it a go. Although I suspect it'll need some extra code. Maybe we need to use the Hermes |
Unfortunately, not much progress. I couldn't get my Android client to do the When using the working clientID, the
Maybe that's helpful to someone down the line who makes more progress. |
I used mitm proxy to see what my desktop client was doing in response to If I use the Sonos client ID, the client receives a valid response and it sends me the returned token in the
But if I use any other client ID, the client gets the following and gives up:
For librespot, we could probably hardcode the Sonos client ID in |
I also noticed that Spotify is usually making some checks on the Thanks for your research! Currently, I don't have time to code and test something. If you or anyone ever find the need for and the time, don't hesitate to make a PR! |
No problem, I'll probably add some of this to the librespot docs at some point. |
Just curious if anyone has made progress on handling the It sounds like the client is exchanging an access token for an authorization_code token. If that is the case, isn't the access token bound to a specific clientId (Sonos constant of |
No progress from my side. I don't have any official receiver, so I can't try anything. Sorry and good luck! |
@TimotheeGerber |
So, reading again what I wrote last year, I think I must have been confused...
I'm not sure what I was thinking here. You cannot exchange a short-lived access token for an authorization code, that makes no sense. Surely the client was grabbing a new access token to then pass on to the sonos device for it to use. On top of this there is sanity checking of the audience parameter, for some reason? So in theory the player should be able to use the access token with the Spotify Web API. In my efforts at librespot-org/librespot#1098 I had lots of problems using that access token. However, I was trying to do something more complicated than simply use it for Web API requests, it might work just fine for that. I hope that makes sense. |
I guess my biggest question is what's in the Spotify Connect Zeroconf API I know the blob layout for the
One would think it would be some sort of serialized token, instead of a formatted blob structure? My only goal at this point is to "wake" the Sonos device up, so that it will be listed in the Spotify Connect active device list. The fact that it is implementing the Spotify Connect Zeroconf API endpoints ( |
I think the format is the same except password is replaced with access token. I vaguely remember dumping it out and the "access token" I got looked vaguely sensible. I think (I don't remember exactly) that's what I implemented in the PR I linked. I could try and resurrect this but time is more scarce these days. |
@kingosticks Regarding the access token, can you recall if:
I would assume that it's a Spotify Webservices API access token, and am also assuming that it should have the I reviewed the PR changes, but did not see anything Sonos specific in that code. Note that I am not too familiar with librespot though, so no surprise there. I'm learning though! |
It was a Spotify Web API token, my earlier post specifies the endpoint and the scope. Everything here is about Spotify, it just happens to be running on a Sonos device. |
@kingosticks
Where I am stuck is the call to the Login5 endpoint. I need to find a way to use this endpoint with a Spotify userid and password (instead of a cached token), preferably in Python. The closest thing I could find is the spotify-login PHP code on GitHub, but not sure if that is what I need. Am I even in the ballpark with this? Interested to hear your thoughts on it. Thanks - Todd |
I've actually been working on this again from a slightly different angle (desktop login) following Spotify's temporary breakage of user+password login, which we've since heard they intend to make permanent so librespot (and friends) need an alternative. Spotify's desktop app login is currently as follows librespot-org/librespot#1308 (comment):
And I've done a PR to support this oauth-style flow at librespot-org/librespot#1309 which also documents some limitations I found when experimenting with session authentication using an access token. User and password authentication with Login5 might still be possible in the future using the Android client-id and solving the hashcash challenges, that's not clear yet. That's what the Spotify Android app currently does but maybe they'll change that too. So back to what we were trying to do here, I would expect that the Login5 call you see is using a "stored credentials" blob rather than an access token. I still think it's backwards to try and get an authorization code from an access token, so struggling to get my head around that but maybe, I've not looked again in detail at this flow again (yet). He big take-away here is that user+password login is being deprecated by Spotify. So you'll need to factor that into your plans. |
@kingosticks Traced via Fiddler To re-produce the Spotify Connect authorization flow:
|
And here's an old example trace I have:
|
Thank you very much @kingosticks (and all the librespot community that helped you) for your PR about OAuth flow! As the username/password flow is broken (at least for me), I switched to the OAuth flow by default in this tool too. It works well with my versions of librespot at least. Don't know about officially supported hardware, I still don't have one. @thlucas1 It seems almost everything is here to implement the |
@TimotheeGerber Thank you, I already had it working. There is an extra step for the user in my process to run a Python script to allow them to authorize the access request, but other than that it works great. |
I randomly dumped the getInfo response from my Sonos Roam and noticed it was sending
tokenType":"authorization_code"
along with aclientID
and all the usual stuff. I've not yet tried it with this tool to see what happens when I respond with an access token. Has anyone got this flow working?The text was updated successfully, but these errors were encountered: