I'm having a hard time trying to authenticate my spotify
app on localhost
. I have my redirect_uri
set as localhost:8888/callback
(have also tried it with http://
) at my developer account, but I get this error page when terminal prompts me to enter the URL I'm being redirected to.
I am running my server using python -m SimpleHTTPServer 8888
, and entering at terminal python script.py username
.
This is my Python script:
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, client_id='myId', client_secret='mySecret', redirect_uri='localhost:8888/callback')
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
This is the log:
token_info = sp_oauth.get_access_token(code)
File "/Library/Python/2.7/site-packages/spotipy/oauth2.py", line 210, in get_access_token
raise SpotifyOauthError(response.reason)
spotipy.oauth2.SpotifyOauthError: Bad Request
What could be wrong?
have you tried it without the port number? So replacing
localhost:8888/callback
with this:
localhost:/callback