Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to process request due to missing initial state. #4256

Open
chaitanya4288 opened this issue Jan 4, 2021 · 275 comments
Open

Unable to process request due to missing initial state. #4256

chaitanya4288 opened this issue Jan 4, 2021 · 275 comments

Comments

@chaitanya4288
Copy link

chaitanya4288 commented Jan 4, 2021

[REQUIRED] Describe your environment

  • Windows 10, Android 10
  • Google chrome
  • firebase js sdk version: 7.24.0
  • firebase auth

[REQUIRED] Describe the problem

When trying to do sign with redirect (social login: google/facebook), many of our users are getting the following error:
Unable to process request due to missing initial state. This may happen if browser sessionStorage is inaccessible or accidentally cleared.

Steps to reproduce:

Not able to reproduce this. But it occurs very frequently for many of our users.

4e2fa850-d8cf-41d4-a066-764d0f63c135

@google-oss-bot
Copy link
Contributor

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

@Carlex300
Copy link

i have the same problem, heeeeeelp

@NicholasHazen
Copy link

Seeing the same issue in production for our react app on android.

@dazzyjong
Copy link

same issue on the Facebook in-app browser while the user does Facebook sign-in.

@Hamaad-Siddiqui
Copy link

Seeing same issue on Android using Next.js & Firebase v8.2.1

@atulgpt
Copy link

atulgpt commented Jan 9, 2021

+1

@AndresMWeber
Copy link

AndresMWeber commented Jan 9, 2021

Seeing the same consistently on Android + Chrome deployed on Vercel with Next.JS & Firebase v8.2.1 both using signInWithPopup and signInWithRedirect. Worth noting that this functions as intended in Android + Firefox.

@Gobbees
Copy link

Gobbees commented Jan 10, 2021

+1 on NextJS using Firebase v8.2.2

@juergengunz
Copy link

+1

@sthielen
Copy link

+1 - anyone managed to resolve?

@kenji7157
Copy link

kenji7157 commented Jan 21, 2021

this issue, the version doesn't matter.

If you are using a custom domain, you have to set Client SDK configuration. you set it?

firebase.initializeApp({
  apiKey: '...',
  // Replace the default one with your custom domain.
  // authDomain: '[YOUR_APP]/firebaseapp.com',
  authDomain: 'auth.[YOUR_DOMAIN]'
});

https://cloud.google.com/identity-platform/docs/show-custom-domain

@KevinLourd
Copy link

@kenji7157 I have the same issue on the Facebook in-app browser while the user does Facebook sign-in.
I am not using a custom domain

@jaredtbrown
Copy link

I am having the same error using the GitHub auth provider when using my Android device + Chrome. I have tried using the signInWithRedirect and signInWithPopUp methods and tried using the FirebaseAuthUI but all returned the same result.

Using the same Android device and Firefox, however, works just fine.

@raevilman
Copy link

raevilman commented Jan 25, 2021

I was using GitHub auth provider with custom domain configured on Netlify as CNAME.
Although GitHub configuration in firebase console tells me to use the default redirect URL(eg. abc-989d.firebaseapp.com) not the custom one I had created. But that was causing the error in question.

Once I updated my GitHub OAuth application with the new custom URL everything worked fine.

Eg: https://auth.custom-domain.com/__/auth/handler this is what I've set in app configuration on GitHub.

@KevinLourd
Copy link

@raevilman I moved to custom domain and I still have same issue. Althought I am not using Github as DNS provider but gandi.net

@raevilman
Copy link

@KevinLourd
For context:
I was trying to change domain name shown on Google sign-in consent page.
And I am using Netlify as hosting provider, GitHub as OAuth.
I've documented the steps here

~HIH

@louisameline
Copy link

louisameline commented Jan 25, 2021

Same here. Using cordova wkwebview, inappbrowser, a well configured custom auth domain. I've seen it happen more on iOS than Android.

What is weird is that the second time I try to sign in with Facebook (when I don't have to enter my credentials anymore), it works fine. When it's with AppleId (which asks me my credentials every time), the second time fails with the same result.

Edit: now it seems that it doesn't always work the second time with Facebook, it has an inconsistent behaviour.

@jaredtbrown
Copy link

jaredtbrown commented Jan 26, 2021

I have now pointed the auth domain to point to the auth.custom-domain.com domain I have created but still the same error for Android + Chrome.

@louisameline
Copy link

Anyone at Firebase looking into this? If our users can't log into our apps, it should be priority #1 no?

@KevinLourd
Copy link

KevinLourd commented Jan 26, 2021

@louisameline I have contacted the Firebase few days ago, but they asked for a minimum reproductible example. Would anyone have reproduced one by any chance? cc @hsubox76

@louisameline
Copy link

I guess I can share a piece of my app if it stays private. Let me work something out

@Hamaad-Siddiqui
Copy link

@KevinLourd I have a project ( still in development ) which is getting the same issue. Here is the repo : https://github.com/Hamaad-Siddiqui/Fast-Feedback-2.0

@sam-gc
Copy link
Contributor

sam-gc commented Jan 26, 2021

Hi folks-- for those of you who've been able to reproduce it yourselves, what are the circumstances specifically? For example, are the browsers running in private/incognito mode? Are third-party cookies disabled (this shouldn't apply but in some cases the way this is implemented in the browser could cause issues)?

@sam-gc
Copy link
Contributor

sam-gc commented Jan 26, 2021

One more thought since this issue could be caused by numerous things.

There was a recent bug in the Firebase Console that caused the wrong auth domain to be presented when enabling other OAuth providers. The domain had "-default-rtdb" at the end and this would lead to the wrong configuration with the other provider. Since the "missing initial state" issue could be caused by several different things, it would be worth double checking your configuration for GitHub/Microsoft/etc sign in. The bug in the Console was resolved late December and it now displays the correct value, but depending when you looked at the Console to configure the providers you may still have issues.

@sthielen
Copy link

@samhorlbeck I've unfortunately not been able to reproduce it consistently, but from the reports I have seen it appears to be happening inside the Instagram WebView on iOS when trying to sign in with Facebook or Google. This happens if someone links to our site in their Instagram bio, where tapping that link doesn't intent to another browser but opens Instagram's in-app, webview-based browser.

Based on that, it feels like it might have something to do with these apps' implementations of UIWebView or WKWebView? Though I can verify that sessionStorage/localStorage both work as expected in those browsers, so it's possible that's a red herring. Let me know if I can help in any other ways, and I'll see if I can find anyone who can reliably reproduce it. Thanks!

@Hamaad-Siddiqui
Copy link

@samhorlbeck Just go on a mobile to the website that I provided you the repo of https://fast-feedback-dev.vercel.app
And click on Sign In with GitHub.
The error will happen every time you go from Chrome it doesn't seem to occur on Firefox so it seems to me maybe there is something wrong with chrome ? I am specifically talking about the mobile versions...

@FilipeMarch
Copy link

FilipeMarch commented Feb 3, 2023

After two years and not a single reliable solution was provided by anyone from Firebase to this issue, the best thing is to leave Firebase and create your own authentication system with FastAPI.

Probably you can learn FastAPI tutorial in less than a week, while this issue with Firebase it seems it will never be solved. Every week I receive emails about different people arriving at this issue in all kinds of apps. For years...

At least that's what I have done, zero issues. What's the point of using Firebase if it doesn't work reliably for all phones / browsers?

Don't wast your time, guys. Years has passed... the issue is the same as always. Unpredictable, happen to some people in some phones or in some browsers, sometimes it happens sometimes it does not. I don't recommend anyone to use it.

Leave Firebase and learn FastAPI (or any other framework, doesn't matter)

@wajeshubham
Copy link

When I switched from Github to Google for authentication, the error was gone. The Github login works on desktop browsers as well as on mobile devices only when the browser is incognito.

Using mobile browsers in NON-incognito mode results in the above error.

Since I'm unable to figure out how to handle it, I'm going with Google authentication for now. If anyone has experienced the same issue with Github login and has resolved it, please let me know.

wajeshubham added a commit to wajeshubham/snippng that referenced this issue Feb 3, 2023
- Reason: FIREBASE ISSUE: firebase/firebase-js-sdk#4256
- Add google icon
- Handle navigator exception
@adipascu
Copy link

Works on Chrome, fails on any other browser. Why is that Google?

@dimitriadamou
Copy link

Consistently having this issue; using Google IdP for multi-tenant; was working perfect until 4 months ago and iOS 16 - have been unable to progress.

@mesqueeb
Copy link

Works on Chrome, fails on any other browser. Why is that Google?

Please note that "chrome" is completely different again wether it's windows / iOS / Android / macOS / Linux /...

So your comment is quite vague and not really actionable

@pauloteixeirajr
Copy link

Works on Chrome, fails on any other browser. Why is that Google?

Please note that "chrome" is completely different again wether it's windows / iOS / Android / macOS / Linux /...

So your comment is quite vague and not really actionable

The issues' been open for +2 years; no action from anyone and you are worried about this one comment not being actionable.

@gorkemunuvar
Copy link

gorkemunuvar commented Feb 28, 2023

Having the same issue with Flutter + Apple Sign In on Android. I've ran the app on a real device using Brave as default browser.

@SX-9
Copy link

SX-9 commented Mar 4, 2023

so the only auth provider that does not work is github, so you probably wanna switch to something else like google

@noook
Copy link

noook commented Mar 4, 2023

I happen to have that issue a lot of time with Google

LunaVoid added a commit to LunaVoid/JoshChat that referenced this issue Mar 9, 2023
Created a working Google Auth using Firebase's built in Authentication system.  Used this guide https://www.youtube.com/watch?v=PJCr_aoOv68 but had some trouble because there is a bug I experienced that is recorded here: firebase/firebase-js-sdk#4256 the resolution seems to be using signinwithpopup instead of signinwithredirect.
@nicholaslythall
Copy link

We are experiencing this in our app. Both on iOS and Android, when signing in with Google and Microsoft.
Sometimes after it occurs it will work if the user tries to sign in a second time.
But recently a client has reported it happening consistently and they're unable to sign in at all.

@LunaVoid
Copy link

Just wanted to comment on this as well and confirm that signin with popup does indeed seem to solve this issue for me on firefox. Turning off enhanced tracking protecting also fixes it on firefox. I haven't tried anything on mobile though.

@dimitriadamou
Copy link

For myself the only solution that worked with Mobile-App was to use an in-app browser rather than the external chrome/safari; the flow works again.

@romk1n
Copy link

romk1n commented Mar 13, 2023

any update on this seems to be caused all the time?

@wiztensai
Copy link

+1

1 similar comment
@kcamson
Copy link

kcamson commented Mar 23, 2023

+1

@Technorocker
Copy link

I am having the same problem on android, the only auth provider I have setup and turned on is the phone authentication. I have setup play integrity and followed all the guides to make sure it was setup properly. Even using the debug "fake number" I setup in firebase console it still opens a browser and shows that missing initial state error.

@teotoplak
Copy link

Same issue here +1

@daviddonayo
Copy link

Same issue

@andrefreitas
Copy link

We are having this issue on the Firebase native SDK for Android. We are not using a custom domain.

If using a custom domain (web SDK) it doesn't happen but we get another sort of problems (doesn't work well with the mobile app).

@OziTFA
Copy link

OziTFA commented Mar 29, 2023

after some research, I will continue with creating custom token and sign with it to avoid this error.

@rikotacards
Copy link

Getting this too.

@prameshj
Copy link
Contributor

prameshj commented Apr 3, 2023

Hi everyone, since this issue has been open for a while and we have many scenarios where the "missing initial state" error can show up, I would like to summarize it here:

The most common case for this error is if the auth helper code and the main application are NOT on the same origin. This can be fixed by following one of the best practices in https://firebase.google.com/docs/auth/web/redirect-best-practices

If you are on the same origin and still seeing this issue, please file a separate issue describing the setup + repro steps. If you are seeing this in mobile, please open an issue in the relevant mobile SDK. Again, a repro app + the browser info will be very useful. Thanks!

@firebase firebase locked as off-topic and limited conversation to collaborators Apr 3, 2023
@DellaBitta DellaBitta added the bug label Jun 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests