0

I am looking to find a simple way to maintain a user's session with firebase auth and be able to get the user's UID from Node and also sign in and out users. I need a way to do this with Node.JS so if anyone knows a way to do this then it would be most appreciated.

I have tried using the standard functions like firebase.auth().currentUser from Node but I get errors saying TypeError: firebase.auth is not a function. This is predictable because there could be multiple users logged in at once on the same server.

Thanks in advance for your help, I really appreciate it :-)

1 Answers1

3

I think you have to choose one or the other. Firebase Auth is optimized for client side rendering to work out of the box with other Firebase services like real-time database, firestore and storage. In that case you would send the ID token to your server when needed.

If you want server side sessions using something like httpOnly session cookies and longer sessions, you have to resort to Firebase Auth's session cookie management solution: https://firebase.google.com/docs/auth/admin/manage-cookies However, this will not work with other firebase services client side.

bojeil
  • 29,642
  • 4
  • 69
  • 76