roostaamir roostaamir - 1 year ago 203
Android Question

What is the `Authorization` part of the http post request of Google's Firebase Downstream message?

I want to try to send a message using google's

messaging service and as the document says, the http request should be something like this:

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

My problem is that I have not idea what
's value should be and when I delete this header and make the request, I get error
.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

Answer Source

According to About Firebase Cloud Messaging Server documentation:


To send a message, the app server issues a POST request. For example:

A message request consists of two parts: the HTTP header and the HTTP body.

The HTTP header must contain the following headers:

  • Authorization: key=YOUR_SERVER_KEY

    Make sure this is the server key, whose value is available in your Firebase project console under Project Settings > Cloud Messaging. Client keys or any other keys are rejected by FCM.

  • Content-Type: application/json for JSON; application/x-www-form-urlencoded;charset=UTF-8 for plain text.

    If Content-Type is omitted, the format is assumed to be plain text.

Hope it helps!