mirror of
https://github.com/ramsayleung/rspotify.git
synced 2026-04-26 07:55:55 +03:00
[GH-ISSUE #370] Database storage for access token #116
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#116
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 @v3lmx on GitHub (Dec 4, 2022).
Original GitHub issue: https://github.com/ramsayleung/rspotify/issues/370
Hello!
Is your feature request related to a problem? Please describe.
I want to store the access token obtained in the Authorization Code Flow with
request_token()in a database, to handle multiple users.Describe the solution you'd like
Either :
spotifyobject is configured with a toggle for DatabaseDescribe alternatives you've considered
I tried implementing a new Trait for
AuthCodeSpotifyto rewrite the functionrequest_token, but quickly encountered private enums and functions (such asparams), so it felt like rewriting the whole crate for a single function.Additional context
The method currently used to get the token is
request_token, and it "stores the token internally" in cache if it is configured, and nowhere if it is not as far as I can tell.I'm pretty new to rust so I may have missed something.
I would be willing to give a try to this issue if you think it is a desired feature, if you can give me some pointers to put me in the right direction :)
@ramsayleung commented on GitHub (Dec 9, 2022):
I think the
get_tokenmethod inBaseClientcould satisfy your need, you could disable the cache and get token from client:github.com/ramsayleung/rspotify@2fe5035531/src/clients/base.rs (L36)Then You could get data from
Tokenand save them into database as you want.@v3lmx commented on GitHub (Dec 9, 2022):
Got it ! It works :)
This method doesn't fetch the token so I didn't think to use it in combination with
request_token()that actually goes to spotify to get it.In case anyone encounters this problem, solution snippet below :