大家好我正在与Flask Dance一起通过Spotify对用户进行身份验证。我已经在我的应用程序中正确列出了uri,但是登录后仍然出现错误。网页上显示 INVALID_CLIENT:无效的重定向URI
代码如下:
from flask import Flask, redirect, url_for
from flask_dance.contrib.spotify import make_spotify_blueprint, spotify
app = Flask(__name__)
app.secret_key = "supersekrit"
spotify_blueprint = make_spotify_blueprint(
client_id="myappid", client_secret="myappsecret", scope=["user-follow-read"])
app.register_blueprint(spotify_blueprint, url_prefix="/spotify_login")
@app.route('/')
def hello_world():
data = spotify.get("v1/me/following?type=artist")
if data.ok:
return data.json()
else:
return "Hello World Hope"
@app.route('/spotify')
def spotify_login():
if not spotify.authorized:
return redirect(url_for("spotify.login"))
data = spotify.get("v1/me/following?type=artist")
if data.ok:
return data.json()
else:
return "Bad Data"
if __name__ == "__main__":
app.run(debug=True)