FCM 与 Postman - 请求缺少身份验证密钥(FCM 令牌) [英] FCM with Postman - The request was missing an Authentication Key (FCM Token)

查看:38
本文介绍了FCM 与 Postman - 请求缺少身份验证密钥(FCM 令牌)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

//身体是这样的

<代码>{到":/主题/新闻",数据":{"extra_information": "这是一些额外的信息"},

//我需要给的通知

通知":{"title": "聊天群","text": "您可能有新消息","click_action":"聊天活动"}}

解决方案

401 错误与您的授权密钥无效或不正确有关.

使用 Postman 时,为 Authorization 的值添加一个 key= 前缀,如下所示:

key=AAA...

有关使用 Postman 发送下游 FCM 消息的教程,请参见下文.

另外,对于您的 notification 消息负载,text 不是有效参数之一,我认为您正在寻找 message.

<小时><小时>

使用 Postman 发送下游消息

要在

注意:始终将您的服务器密钥保密.此处只能看到我的密钥的一部分,所以应该没问题.

(2)

(3)

注意请求成功,响应中包含 message_id.

//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"
        }
    }

解决方案

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)

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

(2)

(3)

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

这篇关于FCM 与 Postman - 请求缺少身份验证密钥(FCM 令牌)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆