Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

`401 The request was missing an Authentication Key #37

Open
bigmosh opened this issue Apr 30, 2019 · 3 comments
Open

`401 The request was missing an Authentication Key #37

bigmosh opened this issue Apr 30, 2019 · 3 comments

Comments

@bigmosh
Copy link

bigmosh commented Apr 30, 2019

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 a 401 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: <TITLE>The request was missing an Authentication Key (FCM Token). Please, refer to section "Authentic (truncated...)

@gdespiritorflex
Copy link

+1 :(.

@smartraysam
Copy link

add Bearer before you key

Authorization: Bearer your server key

@MarcosSarges
Copy link

MarcosSarges commented May 20, 2022

help
Screen Shot 2022-05-20 at 09 35 59
Screen Shot 2022-05-20 at 09 36 12

MY SOLUTION -> NODEJS

(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);
  }
})();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants