首页 > 解决方案 > Firebase 云消息传递 cURL POST 显示错误 403

问题描述

我是 cURL 和 Firebase 的新手。我正在尝试使用 Powershell 使用https://firebase.google.com/docs/cloud-messaging/js/first-message#curl中的以下代码发送 FCM 测试消息(我必须修复一个关闭的位置括号)

这是我正在使用的代码 -

curl -X POST -H "Authorization: Bearer ya29.c.KpAB...." -H "Content-Type: application/json" -d '{
  "message":{
    "notification": {
      "title": "FCM-Message",
      "body": "This-is-a-message-from-FCM"
    },
    "webpush": {
      "headers": {
        "Urgency": "high"
      },
      "notification": {
        "body": "This-is-a-message-from-FCM-to-web",
        "requireInteraction": "true",
        "badge": "/badge-icon.png"
      }
    },
    "token": "fG7.....",
  }
}' https://fcm.googleapis.com/v1/projects/project-f0994/messages:send

但由于某种原因,我收到了这个错误:

{
  "error": {
    "code": 403,
    "message": "Request had insufficient authentication scopes.",
    "status": "PERMISSION_DENIED"
  }
}

我无法弄清楚我可能做错了什么。谢谢。

标签: firebasefirebase-cloud-messaging

解决方案


推荐阅读