0

i am checking if the user is logged

const firebase = require('firebase-admin')
firebase.auth().onAuthStateChanged((user) =>{
      console.log('message1', user)
      if (user) {
        console.log('exist')
      } else {
        console.log('not exist')
      }
    });

but i only get error: Error: FIREBASE_ERROR

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807

1 Answers1

0

You are using the Admin SDK, which has no concept of a signed-in user. All code in the Admin SDK runs under an administrative account, not under a Firebase Authentication user's credentials.

If you want to determine what user is logged in on a client, that is then communicating with the process that runs the Admin SDK, you can do so by getting the ID token for the user on the client, sending that to the server, and decoding and verifying the ID token on the server.

Also see:

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807