烧瓶舞蹈Spotify无效URI

时间:2020-11-10 14:38:54

标签: python flask oauth spotify flask-dance

大家好我正在与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)

这是我在应用程序中注册的重定向uri enter image description here

0 个答案:

没有答案