mirror of
https://github.com/spotipy-dev/spotipy.git
synced 2026-04-27 00:25:54 +03:00
[GH-ISSUE #87] Support refreshing token #42
Labels
No labels
api-bug
bug
dependencies
documentation
duplicate
enhancement
external-ide
headless-mode
implicit-grant-flow
invalid
missing-endpoint
pr-welcome
private-api
pull-request
question
spotipy3
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/spotipy#42
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 @wannabeCitizen on GitHub (Apr 4, 2016).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/87
What is the recommendation of this team for how people should refresh tokens? As it stands all examples are written as though you've just gotten your tokens from a prompt. If I go deep into oauth2.py I can find a private method to refresh tokens however, that requires a whole different object that the standard spotipy instance does not need.
This is a critical part of the library. How do you anticipate this flow working?
@eugenio412 commented on GitHub (Apr 8, 2016):
pulled a request for that
@JeremyGrieshop commented on GitHub (Aug 30, 2016):
I'd like to know this as well. I have a long-running app, it needs to refresh the tokens periodically, and I'd like to know how that should be handled in the main control loop. Try/Catch/login? Timer-based? This isn't very clear.
@eugenio412 commented on GitHub (Aug 30, 2016):
Usually Whwnever I need a token I first check if it's not expired (I saved the expire time together with the token and refresh token), if it's expired I proceed to renew it using the refresh function. You can find it in my fork of Spotipy http://GitHub.com/eugenio412/Spotipy
@JeremyGrieshop commented on GitHub (Sep 4, 2016):
Thanks for the followup.
Are you referring to: https://github.com/eugenio412/spotipy/blob/master/examples/client_credentials_flow.py
Where you use the SpotifyClientCredentials object to manage this? If so, that looks like it manages unauthorized logins. If I want to make authorized API calls, I need a way to pass in the redirect url for authentication.
@eugenio412 commented on GitHub (Sep 4, 2016):
Nope, i war referring to the file https://github.com/eugenio412/spotipy/blob/master/spotipy/oauth2.py where refresh_access_token is declared, you can then use it, but there is no example, just read the code and try to make it work, I use it for my project, so it's working
@stephanebruckert commented on GitHub (Jan 26, 2020):
This is how we can currently refresh the token:
However this looks very messy and we are discussing about a way to improve it here https://github.com/plamere/spotipy/issues/263#issuecomment-578539713. I'm closing this issue in favor of the other one. Please let us know what you think of the suggested improvement