Search code examples
firebasefirebase-authenticationjwtfirebase-consolefirebase-admin

Passing email address in custom token


I have simple backend that can register users and generate jwt's using the firebase-admin package.

When I login with this custom token in firebase console -> authentication the email address is not set. Is there a way to be able to see the email address from there?


Solution

  • You can use the updateUser() method to update the user's email address (detailed docs here):

    admin.auth().updateUser(uid, {
      email: "modifiedUser@example.com"
    })
      .then(function(userRecord) {
        // See the UserRecord reference doc for the contents of userRecord.
        console.log("Successfully updated user", userRecord.toJSON());
      })
      .catch(function(error) {
        console.log("Error updating user:", error);
      });