Why does my firebase Google Auth popup close immediately?
Asked Answered
S

3

5

I'm following this tutorial to learn firebase. I cloned the repo. At step 7, I did what it said (though, actually, there was nothing to do here because the steps were already completed in the repo). When I click the [SIGN-IN WITH GOOGLE] button in the UI, the auth window pops open and closes immediately.

I'm developing in an Ubuntu Guest in VMWare. The following domains are authorized for this app in the firebase console:

  • localhost
  • blahblah.firebaseapp.com
  • 127.0.0.1
  • < my guest ip >
  • < my host/public ip >

The firebase website says ask here. I searched thouroughly first, the (few) other posted solutions didn't work.

Can anyone tell me why this is happening?

Shrewd answered 19/3, 2019 at 21:23 Comment(2)
Any console errors or log?Standardize
@Bognar Nope. In the end I just decided to use one of their competitors (mostly just because of this issue-- I couldn't get further).Shrewd
M
16

Sorry for late reply, and even though you decided to go further using another service provider the below might be helpful for others having the same issue.

The popup could be closed immediately after it opens due to an error which you can catch using step 5 from here: https://firebase.google.com/docs/auth/web/google-signin

Here is a brief snippet of how to do it, just modify signInWithPopup function in public/scripts/main.js:

firebase.auth().signInWithPopup(provider).then(function(result) {
  // code which runs on success
}).catch(function(error) {
  // Handle Errors here.
  var errorCode = error.code;
  console.log(errorCode);
  alert(errorCode);

  var errorMessage = error.message;
  console.log(errorMessage);
  alert(errorMessage);
});

To my experience the errorCode could be something like "auth/unauthorized-domain" and the errorMessage could point to the restricted domain you are accessing from: "This domain (127.0.0.1) is not authorized to run this operation. Add it to the OAuth redirect domains list in the Firebase console -> Auth section -> Sign in method tab."

The solution for me was to use localhost:8080 istead of 127.0.0.1:8080, however 127.0.0.1 also can be added to trusted domains using instructions in the errorMessage.

Your error might be different, but hope it helps to debug. Thanks.

Mcnew answered 12/6, 2019 at 3:14 Comment(0)
G
1

I'm giving an alternative solution for people who come up to similar problems as I did. When I published my project in a domain, the popup window was closing shortly after I call it. Soon after, I found out that I should have added my domain to the Authorised Domains located in Firebase auth settings.

Gargle answered 24/5, 2023 at 9:25 Comment(0)
S
0

The same thing happened to me. The code for debugging that AlexZ005 gave helped me solve my problem.

The problem was that 3rd party cookies weren't allowed in my browser. I allowed them and now it works.

Suzysuzzy answered 10/7, 2020 at 9:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.