[GH-ISSUE #96] Disable token caching #28

Closed
opened 2026-02-27 20:22:41 +03:00 by kerem · 5 comments
Owner

Originally created by @raffomania on GitHub (May 27, 2020).
Original GitHub issue: https://github.com/ramsayleung/rspotify/issues/96

I'm writing a web app for multiple users and would like to save the API token in my database. Is there a way to prevent .spotify_token_cache.json from being created?

Originally created by @raffomania on GitHub (May 27, 2020). Original GitHub issue: https://github.com/ramsayleung/rspotify/issues/96 I'm writing a web app for multiple users and would like to save the API token in my database. Is there a way to prevent `.spotify_token_cache.json` from being created?
kerem 2026-02-27 20:22:41 +03:00
Author
Owner

@ramsayleung commented on GitHub (May 28, 2020):

Is there a way to prevent .spotify_token_cache.json from being created?

.spotify_token_cache.json is the default way to cache the token, there is no way to prevent to create .spotify_token_cache.json now :(

My intution is to add a option of SpotifyOAuth, for example disable_cache,
to prevent rspotify from generating .spotify_token_cache.json which is enable by default.

<!-- gh-comment-id:635127920 --> @ramsayleung commented on GitHub (May 28, 2020): > Is there a way to prevent `.spotify_token_cache.json` from being created? `.spotify_token_cache.json` is the default way to cache the token, there is no way to prevent to create `.spotify_token_cache.json` now :( My intution is to add a option of `SpotifyOAuth`, for example `disable_cache`, to prevent `rspotify` from generating `.spotify_token_cache.json` which is enable by default.
Author
Owner

@raffomania commented on GitHub (Jun 3, 2020):

that option would be awesome!

<!-- gh-comment-id:638058193 --> @raffomania commented on GitHub (Jun 3, 2020): that option would be awesome!
Author
Owner

@ramsayleung commented on GitHub (Jun 4, 2020):

I have completed this feature by adding two separate functions to get access token and refresh token without saving token into cache_path instead of adding a new option to disable cache. I think the current choice leads to less change of the codebase. If you want to know how to use the two new functions, check this example for more details :)
github.com/ramsayleung/rspotify@92984d2bcc/examples/get_access_token_without_cache.rs (L22)

github.com/ramsayleung/rspotify@92984d2bcc/examples/get_access_token_without_cache.rs (L43)

<!-- gh-comment-id:638830217 --> @ramsayleung commented on GitHub (Jun 4, 2020): I have completed this feature by adding two separate functions to get access token and refresh token without saving token into `cache_path` instead of adding a new option to disable cache. I think the current choice leads to less change of the codebase. If you want to know how to use the two new functions, check this example for more details :) https://github.com/ramsayleung/rspotify/blob/92984d2bccaa9d9170f5b7962f1dcc2411b43212/examples/get_access_token_without_cache.rs#L22 https://github.com/ramsayleung/rspotify/blob/92984d2bccaa9d9170f5b7962f1dcc2411b43212/examples/get_access_token_without_cache.rs#L43
Author
Owner

@raffomania commented on GitHub (Jun 5, 2020):

alright, seems like a larger API surface, but it solves my problem so I'm happy :)
Thanks a lot for making this crate and for the quick reply! <3

<!-- gh-comment-id:639375845 --> @raffomania commented on GitHub (Jun 5, 2020): alright, seems like a larger API surface, but it solves my problem so I'm happy :) Thanks a lot for making this crate and for the quick reply! <3
Author
Owner

@ramsayleung commented on GitHub (Jun 5, 2020):

Thanks for your response, I am going to close this issue :)

<!-- gh-comment-id:639380210 --> @ramsayleung commented on GitHub (Jun 5, 2020): Thanks for your response, I am going to close this issue :)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/rspotify#28
No description provided.