Firebase messaging, where to get Server Key?

FirebaseGoogle Cloud-MessagingFirebase Cloud-Messaging

Firebase Problem Overview


Firebase allows us to send notification messages via our own application by making POST request.

This tutorial, gives to us instructions how to make this request. However, there is Authorization field in header where I must to place my own Server key.

Where I can get this Server key? There are no instructions for this.

Firebase Solutions


Solution 1 - Firebase

Solution:

  1. Click the Settings (Cog wheel) icon next to your project name at the top of the new Firebase Console, as per screenshot below: enter image description here
  2. Click Project settings.
  3. Click on the Cloud Messaging tab.
  4. The key is right under Server Key. enter image description here

Solution 2 - Firebase

Take this one: (First answer is right - this one is just to show how the page looks like!) https://support.clevertap.com/docs/android/find-your-fcm-sender-id-and-fcm-server-api-key.html#

enter image description here

Solution 3 - Firebase

UPDATE: As of April 2017 this method does not work. The api_key in google-services.json is only the legacy key. The selected answer is correct.


Deprecated way:

In your project there is a JSON file called google-services.json

Open that file and search for

"api_key": [
        {
          "current_key": "********"
        }

those *** are your server api key

If you dont have that file then you can download it from your app details in firebase account

enter image description here

Solution 4 - Firebase

There are two keys on firebase, the first one is in Settings (Tab General) and its call Web API Key.

The second one and in what you are interesting for is in Settings (Tab Cloud Messaging) its called Server key

Use the second one for push notifications from php.

Solution 5 - Firebase

Updated UI 2022

Here are Steps to get serverKey

  1. GO to firebase console

  2. You can get view like this. if you have Created Project select project else Create new Project by click on Add project. enter image description here

  3. Now you are in Project overview panel.

  4. In Project overview panel in left upper corner click on settings button and go to Project Settings --> Cloud Messaging

enter image description here

  1. That's it. in Project credentials Key and token are mentioned. Copy code and paste it. You are good to go enter image description here

Solution 6 - Firebase

In my case, I did an integration with a 3rd party system and they asked for the "server key" json file.

They what I get it from firebase was: Project Overview -> Project Settings -> Service accounts screen and A press the Generate new private key button. I used that file and everything worked as expected

enter image description here

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMr.DView Question on Stackoverflow
Solution 1 - FirebaseFrank van PuffelenView Answer on Stackoverflow
Solution 2 - FirebaseMike MittererView Answer on Stackoverflow
Solution 3 - FirebaseSaiTej HeerajView Answer on Stackoverflow
Solution 4 - FirebaseJonathan GuerreroView Answer on Stackoverflow
Solution 5 - FirebaseKARNAV PARGIView Answer on Stackoverflow
Solution 6 - FirebaseConstantin PredescuView Answer on Stackoverflow