Can I create a user on Firebase Authentication in Cloud Functions Http Trigger?

后端 未结 5 1054
醉酒成梦
醉酒成梦 2021-01-02 13:18

Is it possible to create users (email/password type) from inside the Cloud Functions? I am searching for reference to this, but found nothing.

5条回答
  •  被撕碎了的回忆
    2021-01-02 13:45

    The createUser() function let's you do just that.

    admin.auth().createUser({
        email: "user@example.com",
        emailVerified: false,
        password: "secretPassword",
        displayName: "John Doe",
        photoURL: "http://www.example.com/12345678/photo.png",
        disabled: false
    })
    .then(function(userRecord) {
        // See the UserRecord reference doc for the contents of userRecord.
        console.log("Successfully created new user:", userRecord.uid);
    })
    .catch(function(error) {
        console.log("Error creating new user:", error);
    });
    

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

提交回复
热议问题