[GH-ISSUE #92] Login issue #45

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

Originally created by @freiermuth on GitHub (Apr 25, 2016).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/92

I've been trying countless different methods, and getting the code and callback, but my application keeps saying "bad request". See below:

# set environment variables
os.environ["SPOTIPY_CLIENT_ID"] = c_id
os.environ["SPOTIPY_CLIENT_SECRET"] = c_secret
os.environ["SPOTIPY_REDIRECT_URI"] = callback_uri
token = util.prompt_for_user_token(username, scope)

and the output:

Opening https://accounts.spotify.com/...output_omitted...

Enter the URL you were redirected to: http://localhost:8888/...output_omitted...

Traceback (most recent call last):
File "./HotUnity.py", line 24, in
token = util.prompt_for_user_token(username, scope)
File "build/bdist.macosx-10.11-intel/egg/spotipy/util.py", line 86, in prompt_for_user_token
File "build/bdist.macosx-10.11-intel/egg/spotipy/oauth2.py", line 210, in get_access_token
spotipy.oauth2.SpotifyOauthError: Bad Request

Originally created by @freiermuth on GitHub (Apr 25, 2016). Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/92 I've been trying countless different methods, and getting the code and callback, but my application keeps saying "bad request". See below: `# set environment variables` `os.environ["SPOTIPY_CLIENT_ID"] = c_id` `os.environ["SPOTIPY_CLIENT_SECRET"] = c_secret` `os.environ["SPOTIPY_REDIRECT_URI"] = callback_uri` `token = util.prompt_for_user_token(username, scope)` and the output: Opening https://accounts.spotify.com/...output_omitted... Enter the URL you were redirected to: http://localhost:8888/...output_omitted... Traceback (most recent call last): File "./HotUnity.py", line 24, in <module> token = util.prompt_for_user_token(username, scope) File "build/bdist.macosx-10.11-intel/egg/spotipy/util.py", line 86, in prompt_for_user_token File "build/bdist.macosx-10.11-intel/egg/spotipy/oauth2.py", line 210, in get_access_token spotipy.oauth2.SpotifyOauthError: Bad Request
kerem closed this issue 2026-02-27 23:20:33 +03:00
Author
Owner

@jdwilkin commented on GitHub (May 13, 2016):

I was also just having this problem and in my case I discovered after some inspection that my callback url had a "#" at the end followed by "=". When pasting the callback url into the console I omitted that portion of the url and it worked! Spotipy needs to be able to properly parse out the code from the callback url

<!-- gh-comment-id:219087708 --> @jdwilkin commented on GitHub (May 13, 2016): I was also just having this problem and in my case I discovered after some inspection that my callback url had a "#" at the end followed by "_=_". When pasting the callback url into the console I omitted that portion of the url and it worked! Spotipy needs to be able to properly parse out the code from the callback url
Author
Owner

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

Yes check the redirect_uri is correct

<!-- gh-comment-id:570077409 --> @stephanebruckert commented on GitHub (Jan 1, 2020): Yes check the `redirect_uri` is correct
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#45
No description provided.