[GH-ISSUE #573] Unable to use refresh_access_token via SpotifyOauth #341

Closed
opened 2026-02-27 23:22:05 +03:00 by kerem · 1 comment
Owner

Originally created by @andyd0 on GitHub (Sep 9, 2020).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/573

Describe the bug
unable to use SpotifyOAuth.refresh_access_token.

Your code

auth = SpotifyOAuth(client_id=keys['client_id'], client_secret=keys['client_secret'], redirect_uri=keys['redirect_uri'])
auth.refresh_access_token(keys['refresh_token'])

Expected behavior
Not return the error - get_access_token() got an unexpected keyword argument 'as_dict'

Output

Couldn't refresh token. Response Status Code: 400 Reason: Bad Request
Traceback (most recent call last):
  File "C:\Users\Andy\AppData\Local\Programs\Python\Python38-32\lib\site-packages\spotipy\client.py", line 211, in _auth_headers
    token = self.auth_manager.get_access_token(as_dict=False)
TypeError: get_access_token() got an unexpected keyword argument 'as_dict'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Andy\AppData\Local\Programs\Python\Python38-32\lib\site-packages\spotipy\oauth2.py", line 532, in refresh_access_token
    response.raise_for_status()
  File "C:\Users\Andy\AppData\Local\Programs\Python\Python38-32\lib\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 "<string>", line 1, in <module>
  File "C:\Users\Andy\AppData\Local\Programs\Python\Python38-32\lib\site-packages\spotipy\oauth2.py", line 541, in refresh_access_token
    raise SpotifyException(response.status_code,
spotipy.exceptions.SpotifyException: http status: 400, code:-1 - Couldn't refresh token: code:400 reason:Bad Request

Environment:

  • OS: Windows 10
  • Python version: 3.8.3
  • spotipy version: 2.15
  • your IDE (if using any): VS Code
Originally created by @andyd0 on GitHub (Sep 9, 2020). Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/573 **Describe the bug** unable to use `SpotifyOAuth.refresh_access_token`. **Your code** ``` auth = SpotifyOAuth(client_id=keys['client_id'], client_secret=keys['client_secret'], redirect_uri=keys['redirect_uri']) auth.refresh_access_token(keys['refresh_token']) ``` **Expected behavior** Not return the error - `get_access_token() got an unexpected keyword argument 'as_dict'` **Output** ``` Couldn't refresh token. Response Status Code: 400 Reason: Bad Request Traceback (most recent call last): File "C:\Users\Andy\AppData\Local\Programs\Python\Python38-32\lib\site-packages\spotipy\client.py", line 211, in _auth_headers token = self.auth_manager.get_access_token(as_dict=False) TypeError: get_access_token() got an unexpected keyword argument 'as_dict' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\Users\Andy\AppData\Local\Programs\Python\Python38-32\lib\site-packages\spotipy\oauth2.py", line 532, in refresh_access_token response.raise_for_status() File "C:\Users\Andy\AppData\Local\Programs\Python\Python38-32\lib\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 "<string>", line 1, in <module> File "C:\Users\Andy\AppData\Local\Programs\Python\Python38-32\lib\site-packages\spotipy\oauth2.py", line 541, in refresh_access_token raise SpotifyException(response.status_code, spotipy.exceptions.SpotifyException: http status: 400, code:-1 - Couldn't refresh token: code:400 reason:Bad Request ``` **Environment:** - OS: Windows 10 - Python version: 3.8.3 - spotipy version: 2.15 - your IDE (if using any): VS Code
kerem 2026-02-27 23:22:05 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@andyd0 commented on GitHub (Sep 10, 2020):

I think the user that posted his solution regarding issues with Oauth posted incomplete code. I'm debugging via clone

<!-- gh-comment-id:690716866 --> @andyd0 commented on GitHub (Sep 10, 2020): I think the user that posted his solution regarding issues with Oauth posted incomplete code. I'm debugging via clone
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/spotipy#341
No description provided.