mirror of
https://github.com/ramsayleung/rspotify.git
synced 2026-04-25 23:45:52 +03:00
[GH-ISSUE #412] Automatically request token on startup #133
Labels
No labels
Stale
bug
discussion
enhancement
good first issue
good first issue
help wanted
pull-request
question
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/rspotify#133
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @kangalio on GitHub (May 19, 2023).
Original GitHub issue: https://github.com/ramsayleung/rspotify/issues/412
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?@ramsayleung commented on GitHub (May 20, 2023):
In the initialized design of this library,
request_tokenis automatically called on the startup when initializing the client, the process ofrequest_tokenis 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_tokenfunction 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
ClientCredsSpotifytorequest_tokenautomatically, but there are three clients inRSpotify, includingAuthCodeSpotify,AuthCodePkceSpotify, which are unable torequest_tokenautomatically, 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_tokenbefore making the first API call@kangalio commented on GitHub (May 23, 2023):
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 commented on GitHub (May 26, 2023):
The requirement could perhaps be put in the type system.
As in, the clients could have a separate type for the uninitialized state.
@github-actions[bot] commented on GitHub (Nov 23, 2023):
Message to comment on stale issues. If none provided, will not mark issues stale
@github-actions[bot] commented on GitHub (Nov 28, 2025):
Message to comment on stale issues. If none provided, will not mark issues stale