-
Notifications
You must be signed in to change notification settings - Fork 633
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
Create credentials from access token #1098
Create credentials from access token #1098
Conversation
Nice addition. If you could resolve that conflict? |
The commercial sdk seems to allow this also: https://developer.spotify.com/documentation/commercial-hardware/implementation/reference/latest/#spconnectionloginoauthtoken |
Will sort tonight. I can change |
Cool, thanks. I am currently setting the username and librespot always uses it when authenticating but I was wondering if that's actually necessary for this login method. This example suggests it isn't. |
051a8d9
to
0900aa1
Compare
It seems you can remove the username from the auth packet when using But then I had some issues when trying to actually play tracks with my token based login. I am sure that was working fine yesterday so I must be doing something silly, it is late. |
Agreed, it would be best to not rely on the |
I thought ouath access tokens were supposed to be opaque. I don't think we've any idea how to extract anything from them. I just want to double check there's no difference between setting username and not setting username during authentication. I think my test last night must have been wonky. I was trying lots of things, including using a different client ID; although, I'm not sure why you'd want to given the default keymaster client IDs seem to work just fine. |
Isn't each application supposed to use its own client id to respect the Spotify Developer Terms ? |
@kingosticks, just as a comment, you can extract the username from the token by relying on the Spotify API, but you'll need token to have the user-read-email+user-read-private scopes for that, so maybe not a good idea to add that part.
In case you are using the Web API, maybe you are facing this issue #1099 after rebasing the code to the dev branch |
I assumed he meant extracting it from the token itself. Using the token to call the API and find the account info doesn't sound interesting. Yes, it could be related to #1099. Hmm. |
About this, because I was already thinking on it, I think it will be nice to confirm if the version 0.4.2 witch relays always on the keymaster client ID can work after switching that by a personal application client id. As those client ids seems to be granted with all the scopes maybe it work, and I think it will be more respectful with their developer terms and probably more secure as they can rotate their client id in the future. I'll give it a try some day but in case someone has already tried it and can share his experience that will be nice. Just to clarified it, I'm not proposing removing the current functionality of relaying on the official app client_id but to add an option to operate with a personal client_id (of course after verifying it works). WDYT? |
OK, so the problem with playback when using access token authentication in the dev branch is real. Here's the log showing what went wrong:
Compared with the regular method using user/pass authentication:
I guess this makes sense from an OAuth point of view: if you've provided a token with certain permissions (scopes), it shouldn't be possible for it to request another token with extra permissions set. So the session you get with token-based auth isn't exactly the same as the session you get with user/pass-based auth. I don't think we realised this and I'm still trying to see if this is reflected anywhere in the login response. I tried again with another token which had "playlist-read" granted in an effort to stop it requesting the new token. But that failed because |
@kingosticks when I used Librespot 0.4.2 authenticated with the mentioned spotify-connect tool using the default-token method, which just sends an access token with just the streaming scope but inside the blob (which should made no difference at the end), I don't think I have any error at all, so I'm not sure that your analysis is correct. |
d9d69ce
to
725ff91
Compare
I was specifically saying that token-based auth ("access or "default" is irrelevant to librespot, as you say) does not work in the dev branch. 0.4.2 and dev are very different. The initial login is the same but when it comes to playback, they work differently. 0.4.2 gets audio data the traditional way via Hermes/Mercury and there's no problem using OAuth login with that. The dev branch gets audio data from Spotify's CDN via HTTP, to do that it first needs to get an OAuth token and then use that to get another token ("clienttoken") for CDN access. There seems to be a problem getting that OAuth token if you originally logged in using an OAuth token. However, I expect you can force the same problem on 0.4.2 if you login using an OAuth token and then try to request a new token. Which you would presumably eventually want to do, since each token has a limited lifetime. |
Oh, I didn't have that context and I wasn't able to understand why the previous version works perfect just with the streaming scope, but make sense, thank you so much for the explanation. Probably is also the origin of the mentioned issue. |
Following this -- let me know when you've got something ready to go. |
I think I'm stuck. If we can't get a token when using this login method, how can we use the CDN? There must be a trick I'm missing. Any experience with 403 from keymaster ? |
Isn't required for token auth.
725ff91
to
cc9611f
Compare
The web player probably uses the playplay HTTP endpoint to get encryption keys, so might not use Mercury anymore at all. |
Yes. I guess if you're only using Mercury (old connect h/w sdk stuff??), it doesn't matter that you can't get a bearer token for the http api. But if you're using the http api (everything newer) and you need a bearer token, in theory you don't need Mercury at all; you've got login5 & clienttoken, the websocket, and spclient. Assuming that's right, this stuff needs login5 to work to be useful in dev. Otherwise we can only login and not stream, which is pointless. It would be useful as is for 0.4, but of course we're done with that branch. So it makes more sense to help get login5 working. I remember there was a person doing it but I can't find their work anywhere. In the process of trying to get this working I've spent a lot of time getting back up to speed with how things work. I've got some notes on what the current Windows app is doing, stuff many people already know but I was thinking I could write it up and update the wiki notes for those that don't. Few things I don't understand:
|
I think someone on Gitter was talking about it, but did not latch onto my proposal to make it a PR. |
@GiviMAD @kingosticks : hey! Did you make any progress on this by any chance? :) |
For dev branch (audio data from the CDN), no. It's blocked on our missing login5 implementation, at least. I'd like to work on resolving that but it's low on my list right now and I'm not currently working on it. |
What's login5 exactly and how is it needed here? As I said here I managed to get streaming working so it's not clear to me what's missing exactly. |
Login5 is a newer version of Spotify's auth. It's what their official clients currently use. Correct me if I am wrong, but you found it working in the 0.4x branch, not the dev branch. I've edited what I originally said at #1098 (comment) to hopefully be clearer. |
It's been a while but I'm pretty sure I was testing with |
I assumed you were using v0.4 since your comment referred to testing with the GStreamer element. Was that assumption wrong? It would be great if my unsuccessful experiments here using dev were incorrect. If you want to share your working patch I'll happily give it a try. |
I just re-tested and you're right indeed. I can re-use the token when using |
What do we want to do with this one? Do we believe we can get this working or shall we unfortunately close? |
Sadly have to close for how I think. And then try again when we have login5 support. |
@gdesmott it looks like Spotify have sorted out whatever the problem was here. We should be able to implement this now, in fact we have to as user+pass support is now broken! |
its working fine, I have code from March that works perfectly |
Same, it works fine here using 299b7de |
They broke it for a day, it's (EDIT: they) fixed now. There're many issues/posts in each of the various librespot implementations that don't use login5 about this. And if you were using cached re-usable credentials you would never have noticed. What I don't know is if they've rolled back all changes i.e. did they leave |
Does it make sense to tag a release with all the auth fixes if it's breaking to ensure people that use tagged releases are aware if there's breakage/changes needed there? |
Spotify fixed it themselves, you should not need a new release. |
@kingosticks Hermes isn't (as you know) even HTTP, so in my view it should only be used if its the only option, which in this case its not since login5 exists. I would strongly recommend moving to login5 if its not already done |
New API method and example relating to #1086