Open Mister-SOSA opened 1 year ago
Check if this helps https://github.com/weibeu/Flask-Discord/issues/56#issuecomment-985147104 Additionally, re-check just in case that your callback URL configured in config and that on dashboard are exactly same. Including http/https URL scheme
I feel fairly confident that I have done this part correctly, but anything is possible when I take on a project. Here's what I have:
In main.py
:
app.config["DISCORD_REDIRECT_URI"] = "http://XXXXX.net/callback/"
On my Discord Developer Dashboard:
http://XXXXX.net/callback/
What appears in the addressbar after I click "Authorize":
http://XXXXX.net/callback/?code=NfqYd9YQqieAGCEjHhhHUeXceBr3hz&state=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfX3N0YXRlX3NlY3JldF8iOiJxQTV5dzU2dHZoY0VMVXI5TmJ2c052NVlqTW5ieEQifQ.DxB1RwizZnLMBFikrGkEQf5OKvFy4QLgrNXu_kKuGuM
My @app.route()
:
@app.route("/callback/")
def callback():
discord.callback() # <--- Error occurs here according to traceback
user = discord.fetch_user()
return redirect('/')
Setting my secret key:
app.config["SECRET_KEY"] = os.urandom(24)
Some newfound information.
In callback(self)
at line 142, self.__get_state()
returns nothing. If I try to print it, it's an empty string, which leads me to believe that this item is not in my session when it is called? That would explain why there isn't enough segments when it's passed to jwt.decode()
Sounds either of the following or something similar could be happening:
Hello @Mister-SOSA - If you still need this to be fixed, you need to change this line. https://github.com/weibeu/Flask-Discord/pull/74
Some Contextual Information: Python v3.10 JWT v.2.6.0 OS: Ubuntu
Firstly, I am constructing a
DiscordOAuth2Session()
like so (I have shuffled up all the values to protect my application):I then specify my callback address and input it into the Discord Developer Panel:
Upon trying to access a
@requires_authorization
location on my site, I am redirected to the Discord OAuth screen, perfect so far. All the information displayed on this screen is correct.As soon as I click "Authorize," I am redirected to what appears to be the correct location on my website, with a Flask traceback indicating some sort of problem with JWT.
The traceback:
It's hard for me to tell exactly what is wrong, as I am not very good at cracking modules open myself, but this is what I was able to find.
app.config["SECRET_KEY"]
tojwt.decode()
print(f'SECRET AS SEEN IN client.py: {current_app.config["SECRET_KEY"]}')
is ran on line 159 ofclient.py
inFlask-Discord
print(jwt)
outputsb''
when ran on line 250 ofapi_jws.py
injwt
I've tried several different types of secrets to no avail, and I am currently torn between this being my own error or not. If someone has more details, please let me know.