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

后端 未结 3 1091
既然无缘
既然无缘 2020-12-30 00:18

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:



        
3条回答
  •  一向
    一向 (楼主)
    2020-12-30 01:02

    According to About Firebase Cloud Messaging Server documentation:

    Authentication

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

    https://fcm.googleapis.com/fcm/send

    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!


    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:

提交回复
热议问题