© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•2y ago•
15 replies
Jelles

Google Auth invalid OAuth state

I've encountered an issue with Google Authentication in my application. Initially, I realized I was missing
@rendermode
@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:

AuthenticationFailureException: The oauth state was missing or invalid.
AuthenticationFailureException: The oauth state was missing or invalid.


Despite the error, I can see that the
g_csrf_token
g_csrf_token
is being set in the cookies (e.g.,
g_csrf_token: xxxxxxxx
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 Link
Frontend (Startup.cs): Pastebin Link

Google Sign-In Button:

<script src="https://accounts.google.com/gsi/client" async></script>

<div id="g_id_onload"
     data-client_id="xxxxxxxxxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com"
     data-login_uri="http://localhost:5083/signin-google"
     data-auto_prompt="false" class="rounded-xl">
</div>
<div class="flex flex-col w-full items-center">
  <div class="g_id_signin"
      data-type="standard"
      data-size="large"
      data-theme="outline"
      data-text="sign_in_with"
      data-shape="rectangular"
      data-logo_alignment="left">
  </div>  
</div>
<script src="https://accounts.google.com/gsi/client" async></script>

<div id="g_id_onload"
     data-client_id="xxxxxxxxxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com"
     data-login_uri="http://localhost:5083/signin-google"
     data-auto_prompt="false" class="rounded-xl">
</div>
<div class="flex flex-col w-full items-center">
  <div class="g_id_signin"
      data-type="standard"
      data-size="large"
      data-theme="outline"
      data-text="sign_in_with"
      data-shape="rectangular"
      data-logo_alignment="left">
  </div>  
</div>


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!
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Google Redirct Auth problem
C#CC# / help
2y ago
✅ stateful versus stateless methods?
C#CC# / help
3y ago
Adding Google/Oauth to Web API + SPA
C#CC# / help
2y ago
Implementing Google OAuth throws an error after logging in
C#CC# / help
2y ago