Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Login Issue #80

Closed
Duncanswilson opened this issue Jan 21, 2016 · 2 comments
Closed

Login Issue #80

Duncanswilson opened this issue Jan 21, 2016 · 2 comments

Comments

@Duncanswilson
Copy link

Hello,

Just up front this may all be my ignorance of this api, but I'm currently not able to be login.

I'm calling

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, 
                        client_id='my_id_here', 
                        client_secret='my_secret_here',
                        redirect_uri='https:\\www.google.com')

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

and the issue I am running into is that when I login my web browser opens and goes to Spotify's error page and when I enter that url I (obviously) run into this:

line 16, in <module>
    redirect_uri='https:\\www.google.com')
  File "/Users/duncanwilson/anaconda2/lib/python2.7/site-packages/spotipy/util.py", line 86, in prompt_for_user_token
    token_info = sp_oauth.get_access_token(code)
  File "/Users/duncanwilson/anaconda2/lib/python2.7/site-packages/spotipy/oauth2.py", line 210, in get_access_token
    raise SpotifyOauthError(response.reason)
spotipy.oauth2.SpotifyOauthError: Bad Request

I've learned that this error is caused by the user already being logged in; but as soon as I logout then the redirect breaks when I attempt to login....

Thanks in advance! :)

@joohoi
Copy link
Contributor

joohoi commented Jan 22, 2016

You might want to change your redirect_uri backslashes to actual forward slashes

https:\www.google.com to https://www.google.com

@stephanebruckert
Copy link
Member

Yes check the redirect_uri is correct

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants