mental32 / spotify.py

🌐 API wrapper for Spotify 🎶
https://spotifypy.readthedocs.io/en/latest/
MIT License
149 stars 38 forks source link

Improvements for authentication flow #25

Closed mikonse closed 4 years ago

mikonse commented 4 years ago

I would like to propose some improvements to the API for initializing Spotify Users. Currently, as of my pull request from a few days ago there are multiple ways to create an authenticated User object: User.from_code, User.from_token, and User.from_refresh_token.

There is two improvements I'd like to make. First combine the from_token and from_refresh_token methods into one, e.g. from_token_info that takes a tuple of optional parameters, access_token, expiry_time, refresh_token and then correctly instantiates and authenticates the User depending on what tokens it got.

The second improvement is the option to add a cache path to store the access and refresh tokens and later on reinitialize the User by just providing the cache path. This would make it easier to have persistent applications where one does not want to go through the oauth flow every time and does not want to bother with storing the tokens themselves.

I have the changes ready and will make a pull request soon, just wanted to open this issue to allow for discussion about the changes.

mental32 commented 4 years ago

@mikonse I'm working on a local v0.8.0 branch that I'll be pushing later, could you make your changes off the current master HEAD off a separate branch?

mental32 commented 4 years ago

Apologies for the delay, I've just pushed and merged v0.8.0.

mikonse commented 4 years ago

Alright, i'll get my changes integrated and then open a merge request.