I'm new to firebase was tryn to login with google and it works fine on localhost:5000 when I use (firebase serve) but when I try to use vsCode server or github pages it doesn't work just google page popup and desapears very quickly without signing in
this is the code for login and log out
        (function() {
  "use strict";
  angular.module("app").controller("logInCtrl", logInCtrl);
  //   inject $firebaseAuth
  logInCtrl.$inject = ["$firebaseAuth"];
  function logInCtrl($firebaseAuth) {
    let $ctrl = this;
    let firebaseAuthObj = $firebaseAuth();
    //login function
    $ctrl.logIn = function() {
      firebaseAuthObj.$signInWithPopup(new firebase.auth.GoogleAuthProvider());
    };
  }
})();
(function() {
  "use strict";
  angular.module("app").controller("mainCtrl", mainCtrl);
  //   inject $firebaseAuth
  mainCtrl.$inject = ["$firebaseAuth"];
  function mainCtrl($firebaseAuth) {
    let $ctrl = this;
    let firebaseAuthObj = $firebaseAuth();
    // watcher on main ctr it will load once website starts and will show the state for login
    firebaseAuthObj.$onAuthStateChanged(function(user) {
      if (user === null) {
        $ctrl.user = user;
      } else {
        $ctrl.user = user.displayName;
      }
      console.log("authStateChanged", user);
      console.log($ctrl.user);
      if (user) {
        console.log("Welcome UID:" + user.uid);
      }
    });
    // signout function
    $ctrl.logOut = function() {
      firebaseAuthObj.$signOut();
    };
  }
})();
the problem was related to the domain name I had to go to firebase authentication and register my domain name under the Authorised domains works fine after that
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With