简体   繁体   中英

How to get the user id of a email from firebase email authentication

I want to access the id (or uid ) of a email from firebase authentication . Its not the id of current users id, so i cant use firebase.auth().currentUser.uid. and i am also not in a position to store the uid in the database at the time of sign up and fetch it. is the anyway to fetch it directly from firebase authentication system

The Firebase Admin SDK supports looking up user information with an email:

admin.auth().getUserByEmail(email)
  .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);
  });

This method returns a UserRecord object for the user corresponding to the email provided.

If the provided email does not belong to an existing user or the user cannot be fetched for any other reason, the Admin SDK throws an error.

Reference: https://firebase.google.com/docs/auth/admin/manage-users

使用 admin.auth().getUserByEmail(email)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM