Fireman Cloud Messaging with Postman:添加授权后立即出现连接错误

问题描述 投票:1回答:2

我正在尝试使用Firebase云消息传递使用Postman到网址https://fcm.googleapis.com/fcm/send进行推送通知。

这是我使用的数据:

method: POST,
headers: {
  "Content-Type": application/json,
  "Authorization": key=<my_api_key>
},
body: {
    "to": "<some_device_key>",
    "notifcation": {
        "title": "Hi",
        "body": "test",
        "subtitle": "Jo"
    }
}

使用“原始”设置添加正文。问题是我立即得到了答复:

Failed response from FCM

但是当我在标题中省略Authorization键时,我得到:

<HTML>
    <HEAD>
        <TITLE>The request was missing an Authentication Key (FCM Token). Please, refer to section &quot;Authentication&quot; of the FCM documentation, at https://firebase.google.com/docs/cloud-messaging/server.</TITLE>
    </HEAD>
    <BODY BGCOLOR="#FFFFFF" TEXT="#000000">
        <H1>The request was missing an Authentication Key (FCM Token). Please, refer to section &quot;Authentication&quot; of the FCM documentation, at https://firebase.google.com/docs/cloud-messaging/server.</H1>
        <H2>Error 401</H2>
    </BODY>
</HTML>

因此,以某种方式将Authorization添加到标题会使请求变得混乱。可能是什么原因?文档的给定部分没有“身份验证”部分。

firebase authorization firebase-cloud-messaging postman
2个回答
1
投票

对于那些即使您选择传统密钥仍然会遇到此问题的人。为了完成这项工作,我不得不要求另一把钥匙。我做的是:我访问了这个网站:https://console.developers.google.com/apis/credentials/我点击了我的服务器密钥编辑并要求生成一个新密钥。


0
投票

你用的是哪个键?当我使用“服务器密钥”时,我遇到了同样的问题。在我将密钥更改为“旧服务器密钥”后,请求已停止失败。

这是我的标题:postman_headers

我的身体:request body

您可以在Firebase设置 - >云消息传递中找到密钥。请改用旧版服务器密钥(或迁移到使用服务器密钥的HTTP v1 protocole):

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.