I'm trying to use the Firebase admin auth to get users by phone number via cloud function. Here is the cloud function (minus some request body validation).
module.exports = (req, res) => {
const phone = req.body.phone;
admin.auth().getUserByPhoneNumber(phone).then(userRecord => {
res.send({ user: userRecord });
})
.catch(getUserErr => {
res.status(422).send({ error: getUserErr });
});
};
where phone is E.164 compliant. I'm getting the following error in the response:
Error: could not handle the request
A couple important pieces of information. I'm calling this from a cloud function. Also, I'm currently creating anonymous users with phone numbers (via a different cloud function), not using the phone sign-in provider.
admin.auth().createUser({
phoneNumber: phone
})
I tried turning on the phone auth provider (in addition to the anonymous sign-in provider), but that doesn't seem to matter.
Anyone know what would cause this? The docs are silent on any other setup that's necessary.