I am looking to get the Auth User (s) ID from Firebase through the NodeJS or Javascript API. I added a screenshot for this so that you have an idea what I'm looking for.
Hope you guys help me with this.
Auth data is asynchronous in Firebase 3. Therefore, you need to wait for the event, and then you have access to the current user ID. You cannot get others.
firebase.auth().onAuthStateChanged((user) => { if (user) { console.log(user.uid); } });
https://firebase.google.com/docs/reference/js/firebase.auth.Auth#onAuthStateChanged
Firebase Firebase.getAuth():
Firebase.getAuth()
var ref = new Firebase("https://<YOUR-FIREBASE-APP>.firebaseio.com"); var authData = ref.getAuth(); if (authData) { console.log("Authenticated user with uid:", authData.uid); }
:
Firebase API , Auth User (s) UID.Firebase . ,
"users": { "user-1": { "uid": "abcd..", .... }, "user-2": { "uid": "abcd..", .... }, "user-3": { "uid": "abcd..", .... } }
, uid., !
, .log :
if (firebase.auth().currentUser !== null) console.log("user id: " + firebase.auth().currentUser.uid);