Search code examples
firebasefirebase-authentication

Know what appId is used in firebase authentication


I have 3 web applications in my firebase project, dev, stg and prod. In my front end project, I configured it so that each environment uses an appId. I want to be able to know from which appId is the user authenticated. Is that possible ? enter image description here


Solution

  • You'll find this info in the FirebaseApp options object which, among others, contains the appId.

    For example with the JS SDK v9:

    import { getAuth, onAuthStateChanged } from "firebase/auth";
    
    const auth = getAuth();
    onAuthStateChanged(auth, (user) => {
      if (user) {
         console.log(auth.app.options.appId);
      } else {
        // User is signed out
        // ...
      }
    });