Trying to call a firebase callable functions with firebase, getting error [firebase_functions/unauthenticated] UNAUTHENTICATED.
Here is my firebase function:
exports.getUserInfoWithEmail = functions.https.onCall(async (data, context) => {
let email = data.email;
try {
var user= await admin.auth().getUserByEmail(email)
console.log('running function uid get' + user);
var doc = await admin.firestore().collection("userData").doc(user.uid).get();
return doc.data();
} catch (error) {
return null;
}});
here is my flutter code:
HttpsCallable callable =
FirebaseFunctions.instanceFor(region: 'us-central1')
.httpsCallable("getUserInfoWithEmail");
await callable({"email": search}).then((value) {
...
});
Works perfectly when using the emulator. I don't want to go on cloud console and give access to allUsers, as it has sensible information.
Thanks for your help