I have a users
node in Firebase storing each user's information, but excluding displayName and
email`, which is in firebase auth DB.
One day, I realise that I also need user's displayName
and email
info.
For example, in a page created by another user, I want to display that user's displayName and email.
By given that
displayName
and email
are not stored under the users
node, Is it possible to retrieve the user's displayName
and email
from firebase auth DB (by either normal user or admin)?
or what shall I do for users that were already created in firebase?
Thanks, D
With the AdminSDK it is possible like explained here.
In the doc there is examples for every method, but in your case I guess that you searched for this
admin.auth().getUser(uid)
.then(function(userRecord) {
// See the UserRecord reference doc for the contents of userRecord.
console.log("Successfully fetched user data:", userRecord.toJSON());
})
.catch(function(error) {
console.log("Error fetching user data:", error);
});
You can do things like userRecord.displayName
. The full interface is here.
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