[GH-ISSUE #105] Can't log in to spotify #47

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

Originally created by @AlexEshoo on GitHub (Jun 23, 2016).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/105

So maybe I'm missing something here, but when I run the example program and it gives me a link to visit, I get to a log in screen, but when I try to click log in, nothing happens. I can click the log in through facebook link and this logs me in but when I paste it as the redirected link in spotipy, it raises an exception:

    raise SpotifyOauthError(response.reason)
spotipy.oauth2.SpotifyOauthError: Bad Request

Am I doing something wrong? I have my credentials set as environment variables and I'm using http://example.com/callback/ as my redirect uri

Originally created by @AlexEshoo on GitHub (Jun 23, 2016). Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/105 So maybe I'm missing something here, but when I run the example program and it gives me a link to visit, I get to a log in screen, but when I try to click log in, nothing happens. I can click the log in through facebook link and this logs me in but when I paste it as the redirected link in spotipy, it raises an exception: ``` raise SpotifyOauthError(response.reason) spotipy.oauth2.SpotifyOauthError: Bad Request ``` Am I doing something wrong? I have my credentials set as environment variables and I'm using http://example.com/callback/ as my redirect uri
kerem closed this issue 2026-02-27 23:20:34 +03:00
Author
Owner

@AlexEshoo commented on GitHub (Jun 23, 2016):

I found out that its actually logging me in, but not redirecting anywhere. If I put in a bad password it tells me such. but when I put my real password in and click log in, not a thing happens. If I open up the web player in another tab I'm logged in.

<!-- gh-comment-id:227937873 --> @AlexEshoo commented on GitHub (Jun 23, 2016): I found out that its actually logging me in, but not redirecting anywhere. If I put in a bad password it tells me such. but when I put my real password in and click log in, not a thing happens. If I open up the web player in another tab I'm logged in.
Author
Owner

@AntonioSerrano commented on GitHub (Jan 13, 2017):

Solved it. In order to run the Authorization Code Flow example code provided in the Spotipy's documentation correctly, I specified the redirect URI in line 13 of the example script when calling util.prompt_for_user_token, even when I have done this previously when setting environment variables:

token = util.prompt_for_user_token(username, scope, redirect_uri = 'https://example.com/callback/')

Likewise, do not use https://www.google.com or similar web address as your redirect URI. Instead, try 'https://example.com/callback/' or 'http://localhost/' as suggested here. Do not forget that the redirected URL once you are logged in must have the word code included.

Cheers,
Antonio

<!-- gh-comment-id:272431380 --> @AntonioSerrano commented on GitHub (Jan 13, 2017): Solved it. In order to run the [Authorization Code Flow example code](https://spotipy.readthedocs.io/en/latest/#authorization-code-flow) provided in the Spotipy's documentation correctly, I specified the redirect URI in line 13 of the example script when calling util.prompt_for_user_token, even when I have done this previously when setting environment variables: `token = util.prompt_for_user_token(username, scope, redirect_uri = 'https://example.com/callback/')` Likewise, do not use https://www.google.com or similar web address as your redirect URI. Instead, try 'https://example.com/callback/' or 'http://localhost/' as suggested [here](https://spotipy.readthedocs.io/en/latest/#authorized-requests). Do not forget that the redirected URL once you are logged in must have the word **code** included. Cheers, Antonio
Author
Owner

@AlexEshoo commented on GitHub (Jan 13, 2017):

I've tried what you said, but when I use any of the redirect URIs you suggest the webpage I am brought to has the following message: "INVALID_CLIENT: Invalid redirect URI"
Needless to say, when I past the redirected url in the terminal window I get the same traceback as before.

<!-- gh-comment-id:272565922 --> @AlexEshoo commented on GitHub (Jan 13, 2017): I've tried what you said, but when I use any of the redirect URIs you suggest the webpage I am brought to has the following message: "INVALID_CLIENT: Invalid redirect URI" Needless to say, when I past the redirected url in the terminal window I get the same traceback as before.
Author
Owner

@nplevitt commented on GitHub (Mar 3, 2017):

Hey @AlexEshoo, I don't know if you ever figured this out, but I just solved the same problem.

I found that you have to add your redirect URI that you either include in your bash profile or specify directly in the token prompt to your list of redirect URIs directly in the settings for your Spotify Dev App.

<!-- gh-comment-id:284091619 --> @nplevitt commented on GitHub (Mar 3, 2017): Hey @AlexEshoo, I don't know if you ever figured this out, but I just solved the same problem. I found that you have to add your redirect URI that you either include in your bash profile or specify directly in the token prompt to your list of redirect URIs directly in the settings for your Spotify Dev App.
Author
Owner

@MakonnenMak commented on GitHub (Dec 24, 2017):

@nplevitt So I have specified it within my bash , Spotify Dev App, and within my python file. I still get the invalid error, is it due to the fact that I'm using 'https://example.com/callback/' as my redirect uri?

<!-- gh-comment-id:353756757 --> @MakonnenMak commented on GitHub (Dec 24, 2017): @nplevitt So I have specified it within my bash , Spotify Dev App, and within my python file. I still get the invalid error, is it due to the fact that I'm using 'https://example.com/callback/' as my redirect uri?
Author
Owner

@enriquejosepadilla commented on GitHub (Jan 21, 2018):

@AlexEshoo @mmako1

Have you guys been able to figure it out? Below is my code from the examples and i get INVALID_CLIENT: Invalid redirect URI

token = util.prompt_for_user_token(username, scope, client_id=defintions.SPOTIPY_CLIENT_ID, client_secret=defintions.SPOTIPY_CLIENT_SECRET, redirect_uri=defintions.SPOTIPY_REDIRECT_URI)

<!-- gh-comment-id:359216020 --> @enriquejosepadilla commented on GitHub (Jan 21, 2018): @AlexEshoo @mmako1 Have you guys been able to figure it out? Below is my code from the examples and i get INVALID_CLIENT: Invalid redirect URI `token = util.prompt_for_user_token(username, scope, client_id=defintions.SPOTIPY_CLIENT_ID, client_secret=defintions.SPOTIPY_CLIENT_SECRET, redirect_uri=defintions.SPOTIPY_REDIRECT_URI)`
Author
Owner

@enriquejosepadilla commented on GitHub (Jan 21, 2018):

nevermind :) Had to whitelist it from spotify dashboard!

<!-- gh-comment-id:359216758 --> @enriquejosepadilla commented on GitHub (Jan 21, 2018): nevermind :) Had to whitelist it from spotify dashboard!
Author
Owner

@MakonnenMak commented on GitHub (Jun 2, 2018):

Apologies for the extremely delayed response, I never received a notification for your comment. For future reference though, whitelisting it fixed it for me too.

<!-- gh-comment-id:394059917 --> @MakonnenMak commented on GitHub (Jun 2, 2018): Apologies for the extremely delayed response, I never received a notification for your comment. For future reference though, whitelisting it fixed it for me too.
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#47
No description provided.