Dan Brandesky
Dan Brandesky

Reputation: 21

Spotipy authentication not returning token?

All right folks, I've read all the documentation I can find on spotipy's authentication methods, and I put together a little piece of code to test it out, but I can't get it to work. Basically what happens is I run the application, it gives me a link to log in, I click the link, then the application asks me to paste the redirect URI and press enter. I do that, and nothing happens. I'm really not sure where to go from here, so I could use some help figuring it out!

Here's my test code (obviously I use my own ID, Secret, Username, and URI normally):

import spotipy
import spotipy.util as util

SPOTIPY_CLIENT_ID='myid'
SPOTIPY_CLIENT_SECRET='mysecret'
username = 'myusername'
scope = 'playlist-modify-private'

token = util.prompt_for_user_token(username, scope, client_id=SPOTIPY_CLIENT_ID, client_secret=SPOTIPY_CLIENT_SECRET, redirect_uri='http://www.google.com')

if token:
    print('success')
else:
    print('fail!')

Basically, my code doesn't seem to get to the "if token" section, and I'm not sure why. I actually wouldn't mind finding a way I could authenticate that doesn't involve user interaction, as my application is basically an automated process. Also I have no use for the redirect URI, but I did put a random website into my Spotify application, so it's at least "valid" in that sense. (If I can not use the URI somehow that would also be great!)

Thanks in advance!

Upvotes: 2

Views: 262

Answers (1)

james-see
james-see

Reputation: 13196

I believe you need to put in your redirect url: SPOTIPY_REDIRECT_URL that matches with your app in spotify app you created.

Upvotes: 1

Related Questions