OAuth Twitch Bug?

I am using the AspNet.Security.OAuth.Twitch nuget package and for some reason I am getting an error:
AuthenticationFailureException: redirect_mismatch;Description=Parameter redirect_uri does not match registered URI
AuthenticationFailureException: redirect_mismatch;Description=Parameter redirect_uri does not match registered URI
The URL that it sends you is in HTTP and not HTTPS. Is there a way to change that? I am running this in HTTP mode but I have a cloudflare tunnel making it HTTP. But I even tried doing a reverse proxy with nginx and it had the same issue. I have Discord OAuth working with the sister package and it works just fine
No description
No description
No description
No description
6 Replies
CrownedHaley
CrownedHaleyOP3d ago
Reading the OAuthEvents for .AddTwitch() it says the RedirectUri is exactly the same as the one I added on twitch
No description
hime
hime3d ago
what is your nginx config like, and did you add the http url in the twitch settings
CrownedHaley
CrownedHaleyOP2d ago
server {
listen 80;
server_name twitch2.crownedhaley.com;

location / {
proxy_pass http://127.0.0.1:5147;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
server {
listen 80;
server_name twitch2.crownedhaley.com;

location / {
proxy_pass http://127.0.0.1:5147;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
Yes the url is added to the twitch side
CrownedHaley
CrownedHaleyOP2d ago
I was able to confirm this this works through the proxy so the proxy isn't the problem.
No description
CrownedHaley
CrownedHaleyOP2d ago
No description
CrownedHaley
CrownedHaleyOP2d ago
You have to set this environment variable. Doing it the other didn't work for me: Environment.SetEnvironmentVariable("ASPNETCORE_FORWARDEDHEADERS_ENABLED", "true");

Did you find this page helpful?