What is a Firebase API key?

Firebase API

A Firebase API key is a unique string of characters that allows our applications to interact with our Firebase project. It is essentially a secret token that is generated when we create a Firebase project, and it is required to access any Firebase services, such as authentication and data storage, through the API.

Additionally, the API key allows Firebase to identify legitimate requests from our applications and ensure that only authorized users and services can access the Firebase project and its services.

Firebase API keys are essential for securely accessing Firebase services. If an API key is compromised, unauthorized users can gain access to our Firebase project and its data. Since Firebase projects can store sensitive user data such as passwords and personal details, it is imperative to keep the API key confidential.

Firebase creates a separate API key for each platform. It creates a Browser key for web applications, an Android key for Android applications, and an iOS key for Apple applications. Therefore, all applications on the same platform use the same API key.

Note: A Firebase project can have multiple API keys, but an API key can only be associated with a single Firebase project.

Creating an API key for an application

The easiest way to create an API key for an application is by using the Firebase console.

  1. Open the project's settings by clicking the gear at the top of the left-side panel (refer to slide 1).

  2. Scroll all the way down to the "Your apps" section. If an application to a project has not been chosen, select the appropriate platform to do so (refer to slide 2).

  3. For web applications, we can access the API key directly from the console by selecting the "Config" option. The key can be found in the firebaseConfig object, in the apiKey field (refer to slide 3).

  4. For Android and Apple applications, we have to download the respective configuration files first and open them with a text editor.

    1. For Android applications, download the google-services.json file from the console. The API key can be found in the current_key field (refer to slides 4 and 5).

    2. For Apple applications, download the GoogleService-Info.plist file from the console. The API key can be found in the API_KEY field (refer to slides 6 and 7).

Settings for a Firebase project
1 of 7

Free Resources