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

changed refresh token timer to ensure it refreshes on time #372

Closed
wants to merge 1 commit into from

Conversation

rotywonka
Copy link

I've noticed that whenever I use refresh the access tokens, it doesn't refresh it on time. By refreshing it every 10 minutes, it leaves no room for error of having the access token 'expired'.

Signed-off-by: Tommy Tan tommyytan@gmail.com

Signed-off-by: Tommy Tan <tommyytan@gmail.com>
@spotipy-dev spotipy-dev deleted a comment from Harrison97 Jan 16, 2020
@MaZderMind
Copy link
Contributor

I don't think this does what you think it does.
The access tokens expiry is only currently checked, whenever spotipy.util.prompt_for_user_token is called. An expired token is then refreshed. This does however only work, when the application does not run longer then the remaining lifetime of the token, when spotipy.util.prompt_for_user_token is called.

When the Application runs longer then the remaining lifetime (or longer then 3600s / 1h), the token will expire no matter how tight the window in is_token_expired is.

I think the actual problem you tried to solve is actually solved by #428
I know this PR is quite old, so I don't really expect you to check that, but my guess is that this PR is obsoleted by #428

@stephanebruckert
Copy link
Member

stephanebruckert commented Jan 22, 2020

I'm reopening this, just realised it's not a bad idea. For example it would prevent this situation to happen:

  1. program runs and use token1
  2. 59 minutes, program runs again and re-use token1
  3. 2 minutes later, the program is still running and a call to spotify fails

Another possibility is to only refresh the token when a "token outdated" exception is raised, also avoiding any unneeded calls to /refresh

@MaZderMind
Copy link
Contributor

@stephanebruckert that is not what will happen.

  1. 0:00 Token is created (1h lifetime)
  2. 0:50 App Terminates
  3. 0:55 App starts again
  4. 0:56 API-Call is being made. App identifies the Token is still good and uses the Token. API-Call succeeds.
  5. 1:05 API-Call is being made. App identifies the Token is >59 Minutes old and requests a new one. API-Call succeeds.

@stephanebruckert
Copy link
Member

@MaZderMind agreed, I said that the scenario would be "prevented"

@stephanebruckert
Copy link
Member

This is not needed anymore thanks to #435, closing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants