我一直试图通过重点来验证制作播放列表等等。
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")
我跑了然后我明白了:
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.
我转到网址并发现错误,我将其发回命令行并发现错误。我不知道为什么这个库会这样做,所有其他人通常都会使用用户名,密码,客户端ID和客户端密码。由于某种原因,这个让你走得更远。一些帮助将不胜感激。我正在使用所有正确的信息。我不确定这个重定向网址是什么,也许是因为这会导致问题?
答案 0 :(得分:0)
按照此link获取您的客户端ID,密码和回调uri。然后确保在prompt_for_user_token
调用
这个让你出于某种原因付出额外的一步
额外步骤的原因是您使用url获得的响应包括代码和状态变量,而这些变量又用于获取访问令牌。然后,您最终将Spotify Web API与这些令牌一起使用。如果选中official authorization guide
,您将更好地理解故事