C#C
C#17mo ago
Jelles

Google Auth invalid OAuth state

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


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 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>


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!
Was this page helpful?