Skip to content
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

Automatically request token on startup #412

Open
kangalio opened this issue May 19, 2023 · 4 comments
Open

Automatically request token on startup #412

kangalio opened this issue May 19, 2023 · 4 comments
Labels
enhancement New feature or request

Comments

@kangalio
Copy link

kangalio commented May 19, 2023

Is your feature request related to a problem? Please describe.
Having to call client.request_token().await? once after initializing ClientCredsSpotify and before making the first API call seems a bit arbitrary and easy-to-forget.

Describe the solution you'd like
RSpotify already seems to have auto-authentication capabilities. Could those be expanded to auto-authenticate on the first API call and not have to manually call .request_token() on startup?

@kangalio kangalio added the enhancement New feature or request label May 19, 2023
@ramsayleung
Copy link
Owner

ramsayleung commented May 20, 2023

In the initialized design of this library, request_token is automatically called on the startup when initializing the client, the process of request_token is transparent to the developers, someone will be confused that why did they get an error complaining that the token is invalid, while they don't know they have requested a token implicitly.

So we refactored this client and expose the request_token function to the developers, requiring them to request token explicitly, being aware of the flow of requesting token.

From where I understand, this project is a library, it's not responsible to do everything for the developers, it should expose all possible facilities to developer instead.

Additionally, it's only possible for ClientCredsSpotify to request_token automatically, but there are three clients in RSpotify, including AuthCodeSpotify, AuthCodePkceSpotify, which are unable to request_token automatically, because authorization flows require user interaction in the browser.

In order to maintain a consistent behavior for all clients, it's necessary to require developer to call request_token before making the first API call

@kangalio
Copy link
Author

Ah, I can see how consistency to the other two authentication methods is nice. Still, for me as a fresh user of RSpotify, auto-authentication in ClientCredsSpotify seems less surprising and more user-friendly.

I had assumed RSpotify abstracts over the authorization workflow. However, you have to be aware that the underlying Spotify API requires a token request call. And later, (this ties in with #413) you have to be aware that Spotify requires hourly re-authentication. The fact that RSpotify exposes these details, when they could easily be done by RSpotify itself, surprised me.

Are there other API wrappers that require you to call an extra method after initializing the client to finish initialization? For example serenity doesn't

@blueforesticarus
Copy link

The requirement could perhaps be put in the type system.
As in, the clients could have a separate type for the uninitialized state.

Copy link

Message to comment on stale issues. If none provided, will not mark issues stale

@github-actions github-actions bot added the Stale label Nov 23, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Dec 8, 2023
@ramsayleung ramsayleung removed the Stale label Dec 8, 2023
@ramsayleung ramsayleung reopened this Dec 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants