Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
111
rated 0 times [  117] [ 6]  / answers: 1 / hits: 5996  / 4 Years ago, sun, may 31, 2020, 12:00:00

I am trying to use the Javascript client library for Firebase auth to sign in with a Google account and popup window. However, when I try to sign in, the signin window pops up, I select my Google account, and then it spends about 10 seconds loading (with the blue progress bar moving), then the popup window closes, and shortly after I get the following error message:



code: auth/popup-closed-by-user
message: The popup has been closed by the user before finalizing the operation.


I have enabled Google signin in the authentication section of the Firebase web UI. Below is the code I am using which is pretty much directly copied from the Firebase docs. I have made no other changes to the project config. I started a new project just to test this and have simply run firebase init, enabling only hosting, and enabling Google signin in the authentication web UI.



<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<meta name=viewport content=width=device-width, initial-scale=1 />
<title>Welcome to Firebase Hosting</title>

<script src=/__/firebase/7.14.6/firebase-app.js></script>
<script src=/__/firebase/7.14.6/firebase-auth.js></script>
<script src=/__/firebase/init.js></script>
</head>
<body>
<button id=signin>sign in</button>
<button id=signout>sign out</button>
<script>
const provider = new firebase.auth.GoogleAuthProvider();
const signinButton = document.querySelector(#signin);
signinButton.addEventListener(click, () =>
firebase
.auth()
.signInWithPopup(provider)
.then(function (result) {
console.log(result, result);
})
.catch(function (error) {
console.error(error);
})
);
const signoutButton = document.querySelector(#signout);
signoutButton.addEventListener(click, () =>
firebase
.auth()
.signOut()
.then(function () {
console.log(signed out);
})
.catch(function (error) {
console.error(error);
})
);
</script>
</body>
</html>

More From » firebase

 Answers
14

See this issue: https://github.com/firebase/firebase-js-sdk/issues/3188.


For some users, this is resolved by adding the app domain to the list of authorized domains:

Firebase Console -> Auth -> Sign-In Method -> Authorized Domains -> Add (domain)


[#3625] Friday, May 29, 2020, 4 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
sandra

Total Points: 708
Total Questions: 100
Total Answers: 84

Location: Bosnia and Herzegovina
Member since Thu, Jun 24, 2021
3 Years ago
sandra questions
;