Closed YonLiud closed 3 years ago
Can you confirm these two things in your production deployment:
Also, just in case please do check if you aren't using different domain/subdomain/hostname for your discord create session endpoint and discord callback endpoint.
Can you confirm these two things in your production deployment:
- Flask-Discord (your fork based on) is at latest version.
- pyjwt is latest version.
Also, just in case please do check if you aren't using different domain/subdomain/hostname for your discord create session endpoint and discord callback endpoint.
everything to its latest, confirmed several times
Ah, apologies. I missed looking into your code thoroughly. What's going wrong here is the way you're setting up your app secret key. It's being set to some random bytes at runtime. Which allows for possible cases where your application signs some data with say key1 and then at callback, it tries to verify it using key2 and thus raising the jwt DecodeError exception.
It didn't showed up locally because you might be running a single instance of flask application for testing where the secret key stays fixed through all over application lifetime. However, in production gunicorn may create multiple workers where say your discord session is created on worker1 but the callback happens on worker2, both with entirely different secret keys. Which is potential cause of the issue here.
So the suggestion is to have a cryptographiclly random stuff as secret key fixed in environment variable which should not changed at runtime at least. Changing it indirectly means invalidating all of your users session, cookies, etc.
Weird, it might be possible but when I tried the same without your module and just the vanilla way of doing it (with requests_oauthlib), it works fine...
That might work as in your vanilla version you wouldn't be signing and verifying JWTs using your flask secret key.
ah that is possible, ima try with a permanent key and see if it will fix! thanks anyway!
Server on Production Worked on localhost
There's a reverse proxy by caddy but that's not the issue, I hope at least its not
Using a Forked Version of Flask-Discord (Slightly modified version, no big deal, it didn't work when I try the original version aswell)