0
votes

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

1
i also have signed in the user using firebase authAhmad Reza
Are you using the instance of Firebase that comes from 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
yes i have done that in firebase functions, the error happen on frontend, and i didn't actually use any firebase admin functions, so i doubt that the caseAhmad Reza
and i'm not using firebase fcm so why i get error on that?Ahmad Reza

1 Answers

0
votes

Fixed it, it was because i generated a web app token in firebase setting - cloud messaging. well i didn't use cloud messaging, but i have to setup firebase messaging to make it works and used vapid key.