Open bigmosh opened 5 years ago
+1 :(.
add Bearer before you key
Authorization: Bearer your server key
help
(async () => {
try {
const body = {
registration_ids: [FCM_TOKEN],
data: {
score: "5x1",
time: "15:10",
},
notification: {
title: "teste",
body: "asf",
subtitle: "asg",
},
};
const http = axios.create({ baseURL: "https://fcm.googleapis.com/fcm" });
const headers = {};
headers["Content-Type"] = "application/json";
headers["Authorization"] = `key=${process.env.AUTH_KEY_GOOGLE}`;
http.defaults.headers.post = headers;
const { data: res } = await http.post("/send", body);
console.log(res);
} catch (error) {
console.log(error);
}
})();
The package had been working fine until recently, with noticed on our production server.
full error description below.
Client error:
POST https://fcm.googleapis.com/fcm/send
resulted in a401 The request was missing an Authentication Key (FCM Token). Please, refer to section "Authentication" of the FCM documentation, at https://firebase.google.com/docs/cloud-messaging/server.
response: