Google Auth invalid OAuth state
I've encountered an issue with Google Authentication in my application. Initially, I realized I was missing
Frontend (Startup.cs): Pastebin Link Google Sign-In Button: Could you help me troubleshoot why the OAuth state might be missing or invalid? Any suggestions on how to resolve this issue would be greatly appreciated!
@rendermode
, which was causing updates to fail. However, I'm now facing a problem with identity authentication. When attempting to integrate Google Auth, I keep receiving the following error upon redirection to my backend:
Despite the error, I can see that the g_csrf_token
is being set in the cookies (e.g., g_csrf_token: xxxxxxxx
). I've already configured the endpoints in the Google Console.
Here are the relevant parts of my setup:
Backend (Startup.cs): Pastebin LinkFrontend (Startup.cs): Pastebin Link Google Sign-In Button: Could you help me troubleshoot why the OAuth state might be missing or invalid? Any suggestions on how to resolve this issue would be greatly appreciated!
12 Replies
I am not too sure what the line:
options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
is and if it's required. Same goes for options.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
Full error:
Do you have a query parameter called state when you hit the Authorize endpoint?
Take a look at this https://auth0.com/docs/authenticate/protocols/oauth
Auth0 Docs
OAuth 2.0 Authorization Framework
Learn how Auth0 works with the OAuth 2.0 Authorization Framework.
The code you've posted doesn't really show the login process at all afaict so it's hard to provide anything more than generic OAuth advice
I don't have much other logic I installed identity and google auth that provides that end points and implementation. What excatly should I show? Here is my repo: https://github.com/Jelles/SchedulerBackend
This is my first time implementing OAuth so I am not experienced at all. I will read the link you send see how far I can get
What do you mean by identity?
Asp.NetCore.Identity or IdentityServer?
First one
Ah, in that case I'll back out as I don't have much experience with the built in bits
This problem looks similar, not sure if it helps you?
https://github.com/dotnet/aspnetcore/issues/22125
GitHub
The oauth state was missing or invalid. Unknown location · Issue #...
I created simple ASP.NET Core 3 Web API application. I added new external login oauth provider (let it be Google) and nothing else. Also I created related oauth account that contains my app setting...
I will take a look at that
also found this https://github.com/dotnet/AspNetCore.Docs/issues/14169