首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Spotipy试图用oauth验证

Spotipy试图用oauth验证
EN

Stack Overflow用户
提问于 2015-09-28 07:38:00
回答 1查看 1.1K关注 0票数 4

我一直试着用spotipy来验证来制作播放列表等等。

代码语言:javascript
复制
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")

我运行它,然后我得到这个:

代码语言:javascript
复制
 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.

我转到URL,这是一个错误,我把它发回命令行,它会出错。我不知道为什么这个库这样做,所有其他人通常做用户名,密码,客户端id和客户端机密。这一次让你因为某种原因多走了一步。如果能提供一些帮助,我们将不胜感激。我用的是所有正确的信息。我不知道这个重定向的网址是什么,也许是这引起了问题?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-10-02 22:26:30

按照这个链接获取您的客户端id、秘密和回调uri。然后确保在prompt_for_user_token调用中正确设置了这些参数。

这一次让你因为某种原因多走了一步

执行额外步骤的原因是,使用url获得的响应包括代码和状态变量,这些变量反过来用于获取访问令牌。然后,您最终将Spotify Web与这些令牌一起使用。如果您检查官方授权指南,您将更好地理解这个故事。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32817875

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档