CuriousPaul
CuriousPaul

Reputation: 449

Unauthorized (Error 401) Postman

I am trying to send Push Notifications (using Firebase platform) to my Android app through PostMan Chrome App, but I fail to make it work. I have followed all the instructions on connecting it, but it doesn't work. I can see that this is not an unusual problem, and therefore I have checked this, this, this and many more. Some console layouts/settings have changed and it's not that easy to follow ad literam, but I can see that the Authorization key is the secret.

However, even with all the check-ups and changes I have this: enter image description here

When I'm pressing on SEND to my app, it gives Unauthorized and Error 401. It is obvious what the problem is, but I don't know how to solve it. The Authorization key is the same both in the Firebase console and in the *.JSON file, while the body contains this:

{
  "to": 
    "/topics/NEWS"
  ,
  "data": {
    "extra_information": "This is some extra information"
  },
  "notification": {
    "title": "NEW NOTIFICATION!",
    "text": "Click me to open an Activity!",
    "click_action": "SOMEACTIVITY"
  }
}

I even tried to add the key after to:

And extract from the JSON file can be seen below: enter image description here Nothing worked. Can anyone help me with this, please? Do I need to use some other code from the JSON file? Help?

Upvotes: 0

Views: 5210

Answers (1)

Bob Snyder
Bob Snyder

Reputation: 38289

The key specified in the authorization header must be the Server key or Legacy Server key shown in the Firebase console tab for Project Settings > Cloud Messaging. The Web API key shown on the Project Settings > General tab will not work.

Also, the property for the notification text is body, not text:

{
  "to": 
    "/topics/NEWS"
  ,
  "data": {
    "extra_information": "This is some extra information"
  },
  "notification": {
    "title": "NEW NOTIFICATION!",
    "body": "Click me to open an Activity!", // <= CHANGED
    "click_action": "SOMEACTIVITY"
  }
}

Upvotes: 1

Related Questions