samuelgozi / firebase-auth-lite

A lightweight firebase auth alternative for the browser
MIT License
119 stars 19 forks source link

Error on sign in with google #58

Open rahulkumarsingh73690 opened 3 years ago

rahulkumarsingh73690 commented 3 years ago

Unable to process request due to missing initial state. This may happen if browser sessionStorage is inaccessible or accidentally cleared.

issue-label-bot[bot] commented 3 years ago

Issue-Label Bot is automatically applying the label bug to this issue, with a confidence of 0.96. Please mark this comment with :thumbsup: or :thumbsdown: to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

samuelgozi commented 3 years ago

Sorry for the late response. Can you share some code?

vamsi-manyam commented 3 years ago

Unable to process request due to missing initial state. This may happen if browser sessionStorage is inaccessible or accidentally cleared.

Hey! Were you able to find the solution for this?

samuelgozi commented 3 years ago

Hi, due to lack of free time I didn’t get a deep look into this issue. If you guys can attach the coda that causes the error it will help me.

בתאריך יום א׳, 10 בינו׳ 2021 ב-13:37 מאת vamsi-manyam < notifications@github.com>:

Unable to process request due to missing initial state. This may happen if browser sessionStorage is inaccessible or accidentally cleared.

Hey! Were you able to find the solution for this?

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/samuelgozi/firebase-auth-lite/issues/58#issuecomment-757461367, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADS4MPFB5TKQPRAHNJSJ4DSZGGQDANCNFSM4U2IOENQ .

vamsi-manyam commented 3 years ago

Hi, due to lack of free time I didn’t get a deep look into this issue. If you guys can attach the coda that causes the error it will help me. בתאריך יום א׳, 10 בינו׳ 2021 ב-13:37 מאת vamsi-manyam < notifications@github.com>: Unable to process request due to missing initial state. This may happen if browser sessionStorage is inaccessible or accidentally cleared. Hey! Were you able to find the solution for this? — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#58 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADS4MPFB5TKQPRAHNJSJ4DSZGGQDANCNFSM4U2IOENQ .

Okay ill explain the scenario..I actually implemented the firebase google signing which was working perfectly in both the web and mobile browser. But the issue arises when i share my website link to someone in Instagram/Facebook. My friend clicks the URL it opens in the inbuilt browser of Instagram and in this in-app browser the google signing is not working..it throws an error which i have attached below.

I have also attached the code for google signin!! Thanks in advance WhatsApp Image 2021-01-10 at 10 58 09 `AM

googleSignIn = (event) => {

var app = this.props.firebase.firebaseApp();
var auth = this.props.firebase.firebaseAuth()
console.log("google", app)
var provider = new app.auth.GoogleAuthProvider()
// provider.addScope('https://www.googleapis.com/auth/contacts.readonly');
provider.addScope('https://www.googleapis.com/auth/userinfo.email')
auth.signInWithPopup(provider).then((result) => {
  var token = result.credential.accessToken;
  var user = result.user;

  this.props.firebase.user(user.uid).on('value',snapshot=>{
    let myuser = snapshot.val();
    console.log("signedddinn",myuser)

    if(myuser){
      //user already created..this is just login
      this.props.history.push("/");
    }
    else{
      //user is not existing..so create a user in our db
      this.props.firebase
            .user(user.uid)
            .set({
              username : user.displayName,
              email : user.email,
              photoUrl : user.photoURL

            }).then((u)=>{
              // console.log("pushing success",u)
            }).catch((error)=>{
              console.log("pushing error",error)
            })

      this.props.history.push("/");
    } 
  })
}).catch(function (error) {
  console.log("error in google", error)
});

}

onChange = event => { this.setState({ [event.target.name]: event.target.value }); };

samuelgozi commented 3 years ago

@vamsi-manyam Thank you very much for the detailed example. I know its been a while since this issue was opened, and I'm sorry for that. I will try to solve this this week but I can't anything yet.

clarkdong commented 3 years ago

@samuelgozi @vamsi-manyam I'm not sure if this is an issue with the lib, I suspect it might be an issue with the setting of the client device, like local storage config. My users are seeing the problem intermittently but I can't figure out the pattern yet because not enough data.

sesam commented 3 years ago

localStorage is unsupported/buggy in various situations in Firefox and Safari. We're having trouble with iPad and Firefox users getting into trouble, and one version of Chrome - typically it's the Anonymous/Incognito mode that has limitations, but also Corporate/Phones with some added restrictions and here it looks like also sometimes in web views from other applications. It might be that to get around this localStorage isn't usable. Maybe worth trying to fall back to sessionStorage, as persistence in Incognito / other apps's web views is anyway pointless.

ManojKumarForcebolt commented 3 years ago

Have anyone find the solution to this issue because I am facing the same issue while I am doing Google integration in Electron JS App

samuelgozi commented 3 years ago

Sorry for being late into the conversation. New changes in firefox, safari and also chrome (not sure about the version) block any form of persistent local storage when in incognito. This is is done to block tracking and fingerprinting. I don't think that its the same issue experienced by the issue on top.

As suggested I think that we need to look for a fallback that is not blocked. Im not sure about sessionStorage, I might need to try it.

On a different note. I just wanted to say that Im sorry for not fixing this yet. In the last about 6~ months I didn't have much spare time, and every time I did have it was then filled by other stuff that I had to do. So that's why this project (and any other project on my GitHub account) has been dead.

I can't promise timelines, but I do intend on finding a way to still maintain and update this library. Once I start working again on personal projects this one (all of the "lite" firebase libraries) will be the first to receive my attention.

andesappal commented 3 years ago

@strom2357 I have the same error but for phone sign-in with firebase_auth: ^0.20.1

annaharri89 commented 3 years ago

I'm getting this for the firebase auth sdk as well

masaki-takano commented 2 years ago

Check https://support.apple.com/en-gb/guide/safari/sfri40732/mac

In the Safari app on your Mac, choose Safari > Preferences, then click Privacy.

Select “Prevent cross-site tracking”. --> TURN OFF

LaraCesio commented 2 years ago

I'm facing the same message