I make a callable functions in firebase cloud functions, but whenever i call it i get this error
Uncaught (in promise) FirebaseError: Messaging: A problem occured while subscribing the user to FCM: Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project. (messaging/token-subscribe-failed)
i have seen the example on how to call the callable function in firebase from this https://firebase.google.com/docs/functions/callable#call_the_function but it doesn't work
i also tried this but still getting same error https://cloud.google.com/functions/docs/securing/managing-access-iam#allowing_unauthenticated_function_invocation
here is how i called the functions
const invite = firebase.functions().httpsCallable('inviteUser');
... // some other code
invite({ email, organization: data.name })
backend code
export const inviteUser = functions.https.onCall(({ email, organization }) => {
try {
sendMail(email, organization);
return 'success'
} catch(e) {
return e;
}
})
note i'm using typescript
admin.initializeApp(functions.config().firebase);
? The error you are seeing suggests that you haven't provided the firebase instance you have created with any auth credentials. – Tom Bailey