To create Firebase Authentication users from within Cloud Functions you use the Firebase Admin SDK for Node.js.
To install it, follow the instructions in the documentation. Mostly it's:
$ npm install firebase-admin --save
And then import it into your index.js using:
var admin = require("firebase-admin");
To create a user follow the instructions in this documentation:
admin.auth().createUser({
email: "[email protected]",
emailVerified: false,
phoneNumber: "+11234567890",
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);
});