step-up-labs / firebase-authentication-dotnet

C# library for Firebase Authentication
MIT License
376 stars 129 forks source link

"Unable to process request due to missing initial state" #185

Closed DerKO9 closed 1 year ago

DerKO9 commented 1 year ago

I have forked/cloned the repo and tried running the console app sample. I have added my API key and auth domain to the config. I run the app and choose Google as my provider. It gives me the URI and I paste it into Chrome.

It recognizes the auth domain and shows me all my google accounts I can login into (the black box is the censor my other accounts) image

When I click on my account, It brings me to a page with an error message "Unable to process request due to missing initial state. This may happen if browser sessionStorage is inaccessible or accidentally cleared." image

Is there something I'm missing in my setup to allow this to work?

bezysoftware commented 1 year ago

Which platform, what OS version?

DerKO9 commented 1 year ago

I am on Windows 10 (x64) build 19044.2364 I built and ran Auth.Console.Sample in Visual Studio Code 2022 (latest update) The URI was opened in Chrome Version 108.0.5359.125 (latest update)

The only code change is updating key and auth domain image

bezysoftware commented 1 year ago

That's a rather unfortunate message from Google, but otherwise this is expected. When you see that, copy-past the result url from browser back to console, which will finish sign-in

DerKO9 commented 1 year ago

Oh wow, I apologize for not even trying to paste the url to see if it would work. I have just copy-pasted the url back into the console app and it signed me in successfully. Thank you!

Do you know of a way to automate this process? My project is winforms so I cannot use the convenient FirebaseUI to log my users in and will likely need to use this client.SignInWithRedirectAsync() method. It would be nice if my users didn't have to manually copy and paste the url to sign in.

I have tried Process.Start(uri); to open the url in the user's default browser, but I have no idea how I would get the returned url after they sign in.

I have had success using the Google.Apis.Auth.OAuth2; package for a seamless Google OAuth sign in flow (press button -> Google sign in page opens in the default browser -> user signs in -> Google access token is returned), but I would like to get rid of it and only use Firebase.Auth if I can.

bezysoftware commented 1 year ago

You can try looking at the other UI implementations (WPF & UWP) - they do this - open WebView, listen for this redirect uri and take it automatically. The platform-UI projects are not that code-heavy, largest chunk of work is for supporting email sign in (which needs to be native on each platform). I am planning adding support for other platforms (e.g. Maui) but I do not have the capacity to take them on anytime soon

DerKO9 commented 1 year ago

Alright, I will take a look! Thanks again for your help!

bezysoftware commented 1 year ago

I raised #186 to track any progress