FCM with Postman - The request was missing an Auth

2019-01-03 00:16发布

enter image description here

//body its like this

{
    "to":
    "/topics/NEWS"
    ,
    "data":{
        "extra_information": "This is some extra information"
    },

//notification that i need to give

"notification":{
            "title": "ChitChat Group",
            "text": "You may have new messages",
            "click_action":"ChatActivity"
        }
    }

2条回答
等我变得足够好
2楼-- · 2019-01-03 00:44

The 401 error pertains that your Authorization Key is invalid or incorrect.

When using Postman, add a key= prefix for the value of Authorization, like so:

key=AAA...

See below for a tutorial on Sending Downstream FCM Messages using Postman.

Also, for your notification message payload, text isn't one of the valid parameters, I think you were looking for message instead.



Sending Downstream Messages using Postman

To do this in Postman, you simply have to set the following:

  1. Set request type to POST
  2. In the Headers, set the following:
  3. Set the payload parameters in the Body (*in this example, we used the raw option, see screenshot (2)*)
  4. Send the request to https://fcm.googleapis.com/fcm/send

Screenshots:

(1) enter image description here

Note: Always keep your Server Key a secret. Only a portion of my key is visible here so it should be fine.

(2) enter image description here

(3) enter image description here

Notice that the request was a success with the message_id in the response.

查看更多
时光不老,我们不散
3楼-- · 2019-01-03 00:52

While the answers above are still correct, you may choose to use HTTP v1. This requires Bearer instead of key= and uses an Oauth2 access token instead of a server key string. To view HTTP v1 specifications, please refer to the link below:

https://firebase.google.com/docs/cloud-messaging/migrate-v1

查看更多
登录 后发表回答