devgianlu / go-librespot

Yet another open source Spotify client, written in Go.
GNU General Public License v3.0
53 stars 7 forks source link

Token caching #25

Closed jsv93 closed 3 months ago

jsv93 commented 4 months ago

Is it possible to add token caching similare to how Raspotify works? When the user is using username and password to login, this can also be used to retrieve an access token which can be cached. I am aware that the user can provide an access token themselves, but I figured as the user is already providing the information required to retrieve an access token it would be nice to have it included as a feature.

I have go-librespot operating in a portable device, however each time the device is used I recieve an email notifying of the "new login". Zero-config circumvents this issue but my application does not always allow zero-config to be used.

Thanks again for an creating and awesome build. It has been working well in my application!

devgianlu commented 4 months ago

This is already supported, after logging in successfully go-librespot should create a file called credentials.json containing the stored credentials that can be reused across restarts.

If you enable debug logging you should see something about it.

agneevX commented 2 months ago

@devgianlu after this file is created, how does one go about removing the plaintext credentials from config.yml?

devgianlu commented 2 months ago

@agneevX After the file has been created you can remove the password field, the username field must stay in the config file as a sanity check that the credentials are for the correct user.

agneevX commented 2 months ago

Fair @devgianlu, but I get this error when I do that:

WARN[0000] stored credentials found for wrong username 3163ntztuis6rybst2jgnosqcmfy != <MY_EMAIL_ADDRESS>
FATA[0001] failed running with username and password     error="failed authenticating accesspoint with username and password: failed authenticating: failed login: BadCredentials"
devgianlu commented 2 months ago

@agneevX That probably happens because 3163ntztuis6rybst2jgnosqcmfy is your device credential username. Try using that as your username once the credentials file has been generated.

agneevX commented 2 months ago

Thanks @devgianlu, that worked well. Is playback reporting a planned feature? Also it seems that initial volume steps feature is broken.

devgianlu commented 2 months ago

Is playback reporting a planned feature?

It is eventually. Unlucky it is a very delicate topic that also requires a good amount of work to get done.

Also it seems that initial volume steps feature is broken.

Please open another issue explaining the problem.