Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between Firebase API key (a.k.a Server Key) and the Web API Key?

In Firebase console under Project Settings/General beneath the Project ID field there is a Web API key :

Firebase Web API Key

Where is this used? I know that the Server key found under Project Settings/Cloud Messaging is used as Authorization key to make calls to the firebase console:

Server Key

I have also noticed that in google-services.json ther is an "api_key" property that has a "current_key" value which is different from both keys that I have mentioned. What is that key?

like image 320
DropkickSteve Avatar asked Oct 27 '16 08:10

DropkickSteve


People also ask

What is Firebase server key?

What is a Firebase Server Key? A Firebase Server Key and Firebase Sender ID are required in order to send push notifications to Android mobile app devices. The goal of this section is to provision your Firebase Server Key and Firebase Sender ID for use in OneSignal.

What is my Firebase API key?

An API key is a unique string that's used to route requests to your Firebase project when interacting with Firebase and Google services.

How do I change my Firebase Web API key?

Go to your API account, select a project at the "Select a project" dropdown in the upper left, and "Create Credentials" of the API Key variety. Firebase will link to your key automatically.


2 Answers

From my answer here:

  • current key - nothing is explicitly stated anywhere in the docs where it is used, however, among the 3 services where the google-services.json was originally used for before Firebase (Google Sign-in, Analytics, GCM), I'm guessing it would be between Google Sign-in and Analytics. As also mentioned by @DiegoGiorgini here:

The api_key value in google-services.json is not used by FCM. (it is used by other Firebase libraries)

So it can be for a separate Google non-Firebase or Firebase service.

  • Web API Key - this one I haven't had a chance to use before. However, I've seen other posts wherein this specific API key is used often on Web apps related to Firebase (possibly also for Auth purposes?), but I'm not entirely sure.

  • Server Key - as per the docs:

A server key that authorizes your app server for access to Google services, including sending messages via Firebase Cloud Messaging.

like image 133
AL. Avatar answered Oct 22 '22 19:10

AL.


  • current_key (as per the docs) is the Android key auto-created by Firebase when creating a Firebase Android App. It's NOT used to control access to backend resources. Instead, it's used to identify your Firebase project when interacting with Firebase/Google services. Specifically, it's used to associate API requests with your project for quota and billing.

  • Web API Key (as per the docs): can be used to authenticate users by passing its value to the key query parameter in several API endpoints, e.g., sign up or sign in using email & password, generate refresh token, etc.

  • Server Key (as per the docs): is a server key that authorizes your app server for access to Google services, including sending messages via the Firebase Cloud Messaging legacy protocols.

like image 1
Hasan El-Hefnawy Avatar answered Oct 22 '22 21:10

Hasan El-Hefnawy