我在使用Discord OAuth2进行登录。我尝试过此操作,但它弹出并出现JWT解码错误,
此处是代码:
服务器端:
import os
from flask import Flask
from socket import gethostbyname, gethostname
from flask_discord import DiscordOAuth2Session, requires_authorization
app = Flask(__name__)
app.SECRET_KEY = os.urandom(24)
app.config["DISCORD_CLIENT_ID"] = # Client ID
app.config["DISCORD_CLIENT_SECRET"] = # Client Secrect
app.config["DISCORD_REDIRECT_URI"] = f"https://{gethostbyname(gethostname())}/discord/callback"
app.config["DISCORD_BOT_TOKEN"] = # Bot Token
discord = DiscordOAuth2Session(app)
@app.route("/discord/login")
def login():
return discord.create_session()
@app.route("/discord/callback")
def callback():
discord.callback()
return redirect(url_for("panel"))
返回错误:
DecodeError Not enough segments