4

I've been trying to verify with spotipy to make playlists, etc.

import spotipy
import spotipy.util as util

class buildPlayList():
    def __init__(self,name):
        scope = 'playlist-modify-public'
        self.username=name
        token = util.prompt_for_user_token(self.username, scope,client_id='', client_secret='',redirect_uri='http://example.com/callback/')
        self.sp = spotipy.Spotify(auth=token)
        print self.sp.current_user()

    def make_and_build(self):
        pass
x=buildPlayList("myname")

I run it and then I get this:

 User authentication requires interaction with your
 web browser. Once you enter your credentials and
 give authorization, you will be redirected to
 a url.  Paste that url you were directed to to
 complete the authorization.

I go to the URL and it's an error, I post it back into the command line and it errors. I have no idea why this library does this, all others usually do username, password, client id and client secret. This one makes you go an extra step for some reason. Some help would be appreciated. I'm using all the correct information. I'm not sure what this redirect url thing is, maybe that's causing the problem?

Ghoul Fool
  • 6,249
  • 10
  • 67
  • 125
Eigenvalue
  • 1,093
  • 1
  • 14
  • 35

1 Answers1

0

Follow this link to get your client id,secret and callback uri . Then make sure you set those parameters correctly in prompt_for_user_token call

This one makes you go an extra step for some reason

The reason for the extra step is that the response you get with the url includes code and state variables that in turn are used to get access tokens. Then you finally use Spotify Web API with those tokens. You will better understand the story if you check official authorization guide

woryzower
  • 956
  • 3
  • 15
  • 22