【发布时间】: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)
【问题讨论】: