firebase / firebase-admin-go

Firebase Admin Go SDK
Apache License 2.0
1.15k stars 249 forks source link

{"code":"messaging/mismatched-credential","message":"The caller does not have permission"} #359

Closed bolds07 closed 4 years ago

bolds07 commented 4 years ago

[READ] Step 1: Are you in the right place?

yes

[REQUIRED] Step 2: Describe your environment

[REQUIRED] Step 3: Describe the problem

i'm trying to send a very simple message to a topic with FCM

const messaging = require('firebase-admin').initializeApp({
   serviceAccountId: 'fcm-publisher@igibo-b0b27.iam.gserviceaccount.com',
   projectId: "igibo-b0b27",
   messagingSenderId : '708969080657',
   appId : '1:708969080657:android:0595cd589585bd68'
}).messaging();

exports.sm_jivo_webhook = (req, res) => {

var message = {
  data: {
    activity: 'chat',
  },
  notification: {
    title: 'Resposta do suporte',
    body: 'Volte ao chat para verificar a resposta as suas dúvidas'
  },
  topic: '46f5b99a-5619-3a6b-a0e7-7ca1757b8930'
};

messaging.send(message)
  .then((response) => {
  res.status(200).send(JSON.stringify(response));  })
  .catch((error) => {
   res.status(200).send(JSON.stringify(error));
  });

};

the topic is right the projectId is right
the messagingSenderId is right
the serviceAccuontId is right and is an account with admin privileges to fcm

https://i.ibb.co/DYDKsgr/Clipboard01.jpg