Steps to reproduce:
```Couldn't refresh token. Response Status Code: 400 Reason: Bad Request
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/spotipy/oauth2.py", line 464, in refresh_access_token
response.raise_for_status()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/requests/models.py", line 941, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://accounts.spotify.com/api/token
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/spotipy/util.py", line 88, in prompt_for_user_token
token_info = sp_oauth.get_cached_token()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/spotipy/oauth2.py", line 263, in get_cached_token
token_info["refresh_token"]
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/spotipy/oauth2.py", line 476, in refresh_access_token
headers)
spotipy.exceptions.SpotifyException: http status: 400, code:-1 - Couldn't refresh token: code:400 reason:Bad Request
```
Reason: when oauth2.py attempts to refresh token, Spotify server returns error refresh_access_token() doesn't handle it.
Expected behaviour: show Spotify authentication page in browser to allow user re-authenticate
Suggestion: adds error handling around util.py prompt_for_user_token() line 88
Bumping this, having the same problem. Also occurs when using another spotify app and attempting to run a login sequence with the new client id/ client secret (after I had previously revoked permission on the first app, I had set up a new one to try and get around this issue).
Something similar is happening to me as well.
I built a Spotipy app that successfully ran. I then changed my Client Secret, attached the new Client Secret to the environment variable SPOTIPY_CLIENT_SECRET and receive the following error:
SpotifyException: http status: 400, code:-1 - Couldn't refresh token: code:400 reason:Bad Request
Hi,
I may have a work-around to fix this issue.
I'm developping a little script to import my m3u playlist file to different spotify account. It was perfectly working with the first account but when I wanted to import a playlist to a second spotify account, I got this error.
I noticed in the working directory a .cache-xxxx file which has been created during the first use of spotify.
I suppressed this file and it's works !
Similar to what Nicolas said, there is a .cache in the working directory and if you recycle that it prompts for login again.