[PR #176] [CLOSED] Refresh token from cache when expired #291

Closed
opened 2026-02-27 20:24:07 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ramsayleung/rspotify/pull/176
Author: @borisfaure
Created: 1/10/2021
Status: Closed

Base: masterHead: refresh-expired-token-from-cache


📝 Commits (1)

  • f722e08 Refresh token from cache when expired

📊 Changes

1 file changed (+18 additions, -2 deletions)

View changed files

📝 src/oauth2.rs (+18 -2)

📄 Description

Description

read_token_cache now refreshes token if token is expired.

Motivation and Context

I wanted spotify.prompt_for_user_token().await.unwrap(); to use the cache and refresh tokens

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

How Has This Been Tested?

Tested manually with a token in cache that was expired for about 24h with this dumb code: https://github.com/borisfaure/spotifyctl

This was a draft PR since I wondered about the following:

  • what to do about code duplication on refreshing the token
  • whether to rewrite the cache here
  • what to do on error writing the cache

Ps: This PR is no longer in draft state since it has been more than a month with no interaction from the maintainers: trying to get feedback without the PR being in Draft state.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ramsayleung/rspotify/pull/176 **Author:** [@borisfaure](https://github.com/borisfaure) **Created:** 1/10/2021 **Status:** ❌ Closed **Base:** `master` ← **Head:** `refresh-expired-token-from-cache` --- ### 📝 Commits (1) - [`f722e08`](https://github.com/ramsayleung/rspotify/commit/f722e08c47d892b0dc533876f35a8c0c81ee635f) Refresh token from cache when expired ### 📊 Changes **1 file changed** (+18 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `src/oauth2.rs` (+18 -2) </details> ### 📄 Description ## Description `read_token_cache` now refreshes token if token is expired. ## Motivation and Context I wanted `spotify.prompt_for_user_token().await.unwrap();` to use the cache and refresh tokens ## Type of change - [X] Bug fix (non-breaking change which fixes an issue) - [X] New feature (non-breaking change which adds functionality) - [X] This change requires a documentation update ## How Has This Been Tested? Tested manually with a token in cache that was expired for about 24h with this dumb code: https://github.com/borisfaure/spotifyctl This *was* a draft PR since I wondered about the following: - what to do about code duplication on refreshing the token - whether to rewrite the cache here - what to do on error writing the cache Ps: This PR is no longer in draft state since it has been more than a month with no interaction from the maintainers: trying to get feedback without the PR being in Draft state. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 20:24:07 +03:00
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#291
No description provided.