Closed shillshocked closed 3 years ago
I'm guessing it might possibly have something to do with the new CacheFileHandler(), I haven't used this before and I'm unaware of the syntax.
It has nothing to do with the CacheFileHandler
(what makes you think that?). This class contains the same caching logic as before. What error do you get when you try to make a request with the invalid token? And why do you have to change your Spotify password? I've never had to change my password.
I was reading the changelog and it looks as if the old way of doing things has been deprecated.
Deprecate specifing cache_path or username directly to SpotifyOAuth, SpotifyPKCE, and SpotifyImplicitGrant constructors, instead directing users to use the CacheFileHandler cache handler
Yeah, I don't know, I get that issue once in a while (maybe months, could be more frequently).
Anyways, I messed around a bit more with the code, and I managed to get the scripts running again.
Just curious, can you give me an example of how to use CacheFileHandler in a code snippet? Because I am still using the username authorization.
from spotipy import Spotify, SpotifyOAuth, CacheFileHandler
spotify = Spotify(
auth_manager=SpotifyOAuth(
client_id=client_id,
client_secret=client_secret,
redirect_uri=redirect_uri,
scope=scope_string,
cache_handler=CacheFileHandler(username=username)
)
)
Some of these parameters can be set in the environment variables. See the documentation comments for more information. You may get an extraneous warning message as described in #674. Ignore it.
What error message are you getting when you try to use an invalid token? I'm curious. Do you get a message saying "Refresh token revoked"?
Thanks. Initially the problem was: spotipy "Couldn't refresh token: code:400," but that was just one of the errors.
I deleted the cached token. Made a new app. Put the new variables in to the .bashrc (and any reference in the python code, if applicable). That seemed to get things working. I had a few other issues but that was my own due to a recent update I made.
Sometimes you have to reset your client secret or make a new app to get things working again if your account is bugged. I think this happens every time you reset your password or if your account has been having login issues (perhaps a security feature of Spotify).
If the issue continues more often, I might make an automated way to speed up the reset/redeployment for future occurrences.
If you get a "Couldn't refresh token: code:400," error, then you should only need to delete the cached token info. You shouldn't need to create a new developer application. Try only deleting the cached token info next time.
Describe the bug My Spotify password occasionally doesn't work anymore, which requires a password reset. Doing so invalidates all my old app tokens. I can regenerate those ones (I keep them as local files cached to refresh), but now they aren't working, even with no error message.