【问题标题】:Is there another reason for Illegal redirect_URI error when using Spotify API?使用 Spotify API 时是否存在非法 redirect_URI 错误的其他原因?
【发布时间】:2020-05-04 23:44:28
【问题描述】:

我正在尝试使用 Spotify API(使用 Spotipy),但是我在身份验证步骤中遇到了问题。我正在关注 YouTube playlist 来学习它。为此,我只是跟随下面显示的代码。但是,当它打开我的网络浏览器进行身份验证时,我收到“Illegal redirect_uri”错误。

我尝试在网上搜索并遇到了这个answer,它说这可能是 spotify 网站上的 redirect_URI 中的拼写错误,或者是在我的环境变量中设置的,但是,我进行了四次检查以确保存在没有错字。附上一张图片,显示我的环境变量是什么,以及在 spotify 中设置的 redirect_URI 是什么。

还有其他原因导致我收到此错误吗?

感谢您的帮助。 Spotify Redirect_URI

import os
import sys
import json
import spotipy
import webbrowser
import spotipy.util as util
from json.decoder import JSONDecodeError

#Get the username from terminal
username = sys.argv[1]

# Erase cache and prompt for user permission

try:
    token = util.prompt_for_user_token(username)
except:
    os.remove(f".cache-{username}")
    token = util.prompt_for_user_token(username)

#Create our spotifyObject
spotifyObject = spotipy.Spotify(auth=token)

【问题讨论】:

    标签: python spotify spotipy


    【解决方案1】:

    这可能是一个安全问题,因为 google.com 不会理解 Spotify API 发送的请求的参数。看起来您并没有尝试拦截请求(因为您使用的是 google.com),因此您可以尝试使用 https://localhost:8080/ 作为重定向 url。由于(可能)没有本地运行的服务器,因此不会打开任何页面(并且您会收到错误消息),但您只需复制地址栏中的 url ;-)

    【讨论】:

      猜你喜欢
      • 2018-08-31
      • 2016-09-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-06-18
      • 2015-03-07
      • 1970-01-01
      相关资源
      最近更新 更多