Spotipy: Authorized requests not working

Created on 9 Feb 2018  路  6Comments  路  Source: plamere/spotipy

I created CLIENT_ID and Client_Secret and set my export parameters and also set a redirect_url like the howto says

export SPOTIPY_REDIRECT_URI='http://localhost'

The i run the script

import sys
import spotipy
import spotipy.util as util

scope = 'user-library-read'

if len(sys.argv) > 1:
    username = sys.argv[1]
else:
    print "Usage: %s username" % (sys.argv[0],)
    sys.exit()

token = util.prompt_for_user_token(username, scope)

if token:
    sp = spotipy.Spotify(auth=token)
    results = sp.current_user_saved_tracks()
    for item in results['items']:
        track = item['track']
        print track['name'] + ' - ' + track['artists'][0]['name']
else:
    print "Can't get token for", username

I followed the link from the console on my pc: Opened https://accounts.spotify.com/authorize?scope .....

My Errors:
Illegal redirect_uri
or
INVALID_CLIENT: Invalid redirect URI

What did i wrong ??

Thx, Tatoosh

Most helpful comment

thanks your thread helped me.
For all users new to this:
1) make this your redirect URI: SPOTIPY_REDIRECT_URI='http://localhost:8888/callback/'
2) and add it to your redirect uri whitelist in spotify > app > edit settings > white list

All 6 comments

i forgot the last slash from the export url:
export SPOTIPY_REDIRECT_URI='http://localhost:8888/callback/'
After inserting token i got a new error:

Traceback (most recent call last):
  File "o.py", line 13, in <module>
    token = util.prompt_for_user_token(username, scope)
  File "build/bdist.linux-armv7l/egg/spotipy/util.py", line 88, in prompt_for_user_token
  File "build/bdist.linux-armv7l/egg/spotipy/oauth2.py", line 217, in get_access_token
spotipy.oauth2.SpotifyOauthError: Bad Request

Everything is working now through searching here. there was a typing bug in the docu.

thanks your thread helped me.
For all users new to this:
1) make this your redirect URI: SPOTIPY_REDIRECT_URI='http://localhost:8888/callback/'
2) and add it to your redirect uri whitelist in spotify > app > edit settings > white list

Everything is working now through searching here. there was a typing bug in the docu.

What is the typo? I'm facing the same issue..

Everything is working now through searching here. there was a typing bug in the docu.

What is the typo? I'm facing the same issue..

Same here. Can anyone help?

3 things to check for this problem https://github.com/plamere/spotipy/issues/402#issuecomment-573890067

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gawaineo picture gawaineo  路  3Comments

danielgwilson picture danielgwilson  路  4Comments

basophobic picture basophobic  路  5Comments

fortyTwo102 picture fortyTwo102  路  4Comments

CMoore97 picture CMoore97  路  3Comments