[GH-ISSUE #402] Bad request when using token prompt #236

Closed
opened 2026-02-27 23:21:33 +03:00 by kerem · 2 comments
Owner

Originally created by @gmbroadbent on GitHub (Nov 19, 2019).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/402

import spotipy as sp
import spotipy.util as util
import credentials as c

token = util.prompt_for_user_token(c.sp_username, 'playlist-modify-private', c.sp_client_id, c.sp_client_secret, 'http://localhost:8888/callback/', None)

I have tried a redirect url of http://google.com/ as well, which didn't change anything
I do get successfully redirected

Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.3.3\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "C:\Users\User1\Desktop\Rand\Github\Project\Lab\SE_Prog.py", line 26, in <module>
    token = util.prompt_for_user_token(c.sp_username, 'playlist-modify-private', c.sp_client_id, c.sp_client_secret, 'http://localhost:8888/callback/')
  File "C:\Users\User1\Desktop\Rand\Github\Project\Lab\venv\lib\site-packages\spotipy\util.py", line 86, in prompt_for_user_token
    token_info = sp_oauth.get_access_token(code)
  File "C:\Users\User1\Desktop\Rand\Github\Project\Lab\venv\lib\site-packages\spotipy\oauth2.py", line 217, in get_access_token
    raise SpotifyOauthError(response.reason)
spotipy.oauth2.SpotifyOauthError: Bad Request

Not sure what the "Bad request" is about

Also tried it using using the Idle IDE, same result

Originally created by @gmbroadbent on GitHub (Nov 19, 2019). Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/402 ``` import spotipy as sp import spotipy.util as util import credentials as c token = util.prompt_for_user_token(c.sp_username, 'playlist-modify-private', c.sp_client_id, c.sp_client_secret, 'http://localhost:8888/callback/', None) ``` I have tried a redirect url of `http://google.com/` as well, which didn't change anything I do get successfully redirected ``` Traceback (most recent call last): File "<input>", line 1, in <module> File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.3.3\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import module = self._system_import(name, *args, **kwargs) File "C:\Users\User1\Desktop\Rand\Github\Project\Lab\SE_Prog.py", line 26, in <module> token = util.prompt_for_user_token(c.sp_username, 'playlist-modify-private', c.sp_client_id, c.sp_client_secret, 'http://localhost:8888/callback/') File "C:\Users\User1\Desktop\Rand\Github\Project\Lab\venv\lib\site-packages\spotipy\util.py", line 86, in prompt_for_user_token token_info = sp_oauth.get_access_token(code) File "C:\Users\User1\Desktop\Rand\Github\Project\Lab\venv\lib\site-packages\spotipy\oauth2.py", line 217, in get_access_token raise SpotifyOauthError(response.reason) spotipy.oauth2.SpotifyOauthError: Bad Request ``` Not sure what the "Bad request" is about Also tried it using using the Idle IDE, same result
kerem closed this issue 2026-02-27 23:21:33 +03:00
Author
Owner

@rashad commented on GitHub (Dec 13, 2019):

Big plus one here i've tried almost every possible combination (except the right one apparently) and I keep getting a

line 217, in get_access_token
    raise SpotifyOauthError(response.reason)
spotipy.oauth2.SpotifyOauthError: Bad Request
<!-- gh-comment-id:565431218 --> @rashad commented on GitHub (Dec 13, 2019): Big plus one here i've tried almost every possible combination (except the right one apparently) and I keep getting a ``` line 217, in get_access_token raise SpotifyOauthError(response.reason) spotipy.oauth2.SpotifyOauthError: Bad Request
Author
Owner

@stephanebruckert commented on GitHub (Jan 13, 2020):

3 things to verify to fix this issue:

  • there was a documentation typo https://github.com/plamere/spotipy/issues/232, make sure you call the method this way;

    util.prompt_for_user_token(username,scope,client_id='your-app-client-id',client_secret='your-app-client-secret',redirect_uri='your-app-redirect-url')
    
  • make this your redirect URI: SPOTIPY_REDIRECT_URI='http://localhost:8888/callback/'

  • add it to your redirect URI whitelist in http://developers.spotify.com > app > edit settings > whitelist

<!-- gh-comment-id:573890067 --> @stephanebruckert commented on GitHub (Jan 13, 2020): 3 things to verify to fix this issue: - there was a documentation typo https://github.com/plamere/spotipy/issues/232, make sure you call the method this way; util.prompt_for_user_token(username,scope,client_id='your-app-client-id',client_secret='your-app-client-secret',redirect_uri='your-app-redirect-url') - make this your redirect URI: `SPOTIPY_REDIRECT_URI='http://localhost:8888/callback/'` - add it to your redirect URI whitelist in http://developers.spotify.com > app > edit settings > whitelist
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#236
No description provided.