144

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.

Frank van Puffelen
  • 418,229
  • 62
  • 649
  • 645
Mr.D
  • 5,765
  • 8
  • 41
  • 95

4 Answers4

303

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
Frank van Puffelen
  • 418,229
  • 62
  • 649
  • 645
  • Hey @Frank Van Puffelen, is it the same thing? If i want it for Push Notifications where it says **"Get Application Server Keys"**. I am refering this link: https://developers.google.com/web/fundamentals/getting-started/codelabs/push-notifications/#get_application_server_keys. – divy3993 Jun 14 '17 at 19:29
  • the key has a ... after it, which gives an impression that full key is not being shown here. Also it doesn't have a copy button like legacy server key. Can you kindly update your answer, so that users may know how to copy it. – Ramesh Pareek Jun 22 '17 at 14:00
  • 3
    There is currently a bug in the Firebase console that hides the Copy button in some browsers. A fix is in flight and should be released next week. In the meantime, left click on the Server key label and press Tab key as a workaround. See https://stackoverflow.com/questions/44676388/firebase-dashboard-cant-see-full-server-key#comment76341929_44676388 – Frank van Puffelen Jun 22 '17 at 14:11
  • hi, im trying to send notifcation to Both android and IOS from php, but the server is key is Different for both the apps, should i keep condition to take android's serverkey for android notifications and ios's key for ios messages? – ɹɐqʞɐ zoɹǝɟ Sep 23 '17 at 05:25
  • It's not a tab, but the key is still there under the `Project credentials` heading on a row labeled `Server key`. – Frank van Puffelen Apr 03 '19 at 15:44
  • Is it possible to get this using the command line? I don't see it anywhere in the API docs. – dps Dec 23 '19 at 20:07
  • I can't even see the expected items, but instead I see Web Push Certificates. – Tiny Angel May 26 '20 at 20:54
11

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

Naeem Ibrahim
  • 3,155
  • 1
  • 16
  • 21
Mike Mitterer
  • 5,309
  • 2
  • 35
  • 51
  • hi, im trying to send notifcation to Both android and IOS from php, but the server is key is Different for both the apps, should i keep condition to take android's serverkey for android notifications and ios's key for ios messages? – ɹɐqʞɐ zoɹǝɟ Sep 23 '17 at 05:26
7

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

David Schumann
  • 9,116
  • 6
  • 56
  • 78
  • 2
    FYI, I just spent hours debugging push notification using "current_key" value. Not that I got this from your answer. Turns out you need to get the Servery Key the way the selected answer says. – Dhunju_likes_to_Learn Dec 16 '16 at 03:29
  • 1
    Maybe your answer was right in the past but now (Feb. 2017) it is wrong. The selected answer is right! – Mike Mitterer Feb 24 '17 at 11:53
7

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.