kokarare1212/librespot-python

[REQUEST] Token generation documentation

sa7mon opened this issue · 2 comments

Is your feature request related to a problem? Please describe.
Not really a problem, just wondering if there could be some documentation on how the process works to take the credentials and generate a token from them.

Describe the solution you'd like
I'm working on a Golang app that has a component which needs to query Show info from Spotify. The auth schemes offered by libraries like zmb3/spotify assume the app is a web app and the user will interact with it - this is not the case with my CLI app.

Your library is the best one I've found so far to just take usename+password and generate a valid token for the API. Since my app is in Go, I was hoping to implement a purely Go solution but am struggling to follow the flow through this library.

Anything you can provide about how the process generally works would be greatly appreciated. I understand the library needs to hit 3 different apresolve endpoints - I can see that in the network traffic - but after that I'm a bit lost. I know Protobuf is involved, but not sure how.

Describe alternatives you've considered
If I have to, I could shell out and run a simple Python script using this library to get the token, but I'd really like to avoid that if possible.

Additional context
Thanks for the great library!

ApResolver's accesspoint is used to connect to a tcp socket.
After an internal key exchange, the user is authenticated with a username and password.
The token is obtained by using a special protocol called hm.
https://github.com/kokarare1212/librespot-python/blob/rewrite/librespot/mercury.py#L303-L308
Also, the source code of this repository is not well organized, so it may be easier to refer to the original repository.
https://github.com/librespot-org/librespot-java