I have a long-running script using spotipy. After an hour (per the Spotify API), my access token expires. I am catching this successfully, but I don't know where to go from there in regards to actually refreshing the token. I am using the authorization code flow, not client credentials. Here's how I authorize:
token = util.prompt_for_user_token(username,scope=scopes,client_id=client_id,client_secret=client_secret, redirect_uri=redirect_uri)
sp = spotipy.Spotify(auth=token)
All refresh examples I've seen involve an oauth2
object (ex. oauth.refresh_access_token()
), and the docs list only that function as a method of refreshing your token. It's my understanding that with authorization code flow, you don't need an oauth
object (because you authenticate with prompt_for_user_token()
). If that's the case, how do I refresh my token?