Firebase云消息传递请求Oauth2

时间:2018-06-26 18:22:12

标签: node.js firebase push-notification service-worker pwa

这是我的代码:

curl -X POST -H "Authorization: Bearer XXXX(which is my ApiKey set in firebase.initializeApp())" -H "Content-Type: application/json" -d '{
"message":{
  "notification": {
    "title": "FCM Message",
    "body": "This is an FCM Message",
  },
  "token": "cNPTZlL_1fk:APA91bFGfJxW2nzHOjy-C6_gKod9biZEri8qZIlNEylIjeA5_K8Qa8E9y2JWaWG0zDBI1yVakk0ni2Llo6Sudk7lEDD2H4rwaVXbCf4ax-kk1qL8RCqSd66eHfT4p-wyl6P2LWeidYAy (the token of the user)"
  }
}' "https://fcm.googleapis.com/v1/projects/myproject-b5ae1/messages:send"
{
  "error": {
    "code": 401,
    "message": "Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
    "status": "UNAUTHENTICATED"
  }
}

最大的事情是:

我应该在“授权:承载”中放入什么?? 我在文档中看到了一些东西:

https://firebase.google.com/docs/cloud-messaging/send-message

但是我很难理解这些概念。只需输入F.“ Oauth2”以放入授权即可处理我的消息。

0 个答案:

没有答案