【问题标题】:Unable to abstract auth token from spotify API without using website无法在不使用网站的情况下从 spotify API 中提取身份验证令牌
【发布时间】:2017-09-25 21:50:11
【问题描述】:

我正在尝试从此处https://developer.spotify.com/web-api/authorization-guide 获取重定向 URI 中的授权代码,而无需将其插入浏览器。当我将下面的 auth_url 插入浏览器时,它会很好地重定向到最后的授权代码的 redirect_uri。但是,当我尝试在 python 中执行此操作时,它永远不会重定向。我的代码在这里:

CLIENT_ID='CLIENT_ID'
REDIRECT_URI='http://localhost:8888/callback'

"#Something similar to this"
auth_url = GET https://accounts.spotify.com/authorize/?client_id=CLIENT_ID&response_type=code&redirect_uri=http%3A%2F%2Flocalhost%2Fcallback&scope=user-read-playback-state

r = requests.get(auth_url)
r.url        #equals the auth_url
r.history    #is empty

基本上我只是想找到一种无需打开浏览器即可获取授权码的方法。任何帮助将不胜感激。

【问题讨论】:

    标签: python api python-requests spotify


    【解决方案1】:

    你需要让你的auth_url 变量只是 URL 部分,没有 GET。 requests.get 为您完成 GET 部分。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-05-05
      • 2015-03-01
      • 2018-06-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-16
      相关资源
      最近更新 更多