本文介绍了Google的Firebase Downstream消息的http发布请求中的Authorization部分是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想尝试使用google的 FCM 消息服务发送消息,正如文档所说,http请求应该是这样的:

  https://fcm.googleapis.com/fcm/send 
Content-Type:application / json
Authorization:key = AIzaSyZ-1u ... 0GBYzPu7Udno5aA

{data:{
score:5x1,
time:15:10
},
to:bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1 ...
}



Authorization 的值应该是,当我删除这个头,并提出请求,我得到错误 401:未经授权。我认为这必须是某种API密钥或者某些东西,但我无法在我的项目中找到它。任何人都可以帮助我?



PS:为了测试目的,我目前使用


I want to try to send a message using google's FCM messaging service and as the document says, the http request should be something like this:

https://fcm.googleapis.com/fcm/send
Content-Type:application/json
Authorization:key=AIzaSyZ-1u...0GBYzPu7Udno5aA

{ "data": {
    "score": "5x1",
    "time": "15:10"
  },
  "to" : "bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1..."
}

My problem is that I have not idea what Authorization's value should be and when I delete this header and make the request, I get error 401:Unauthorized.I think this must be some kind of api key or something but I cannot find it in my project. Can anyone help me?

PS: for testing purposes I currently am using this site to send a messsage to my device

解决方案

According to About Firebase Cloud Messaging Server documentation:

Hope it helps!


UPDATE (2016/11/16)

Perhaps you should consider using the FCM token instead of the server keys as the note inside the following screenshot


UPDATE (2016/12/08)

Firebase has upgraded the server keys to a new version and recommended that you upgrade to the newest version. Please see the screenshot below:

这篇关于Google的Firebase Downstream消息的http发布请求中的Authorization部分是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-15 06:35