# 4.5 Firebase Configuration

<figure><img src="https://756612007-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfAZK2jZ3mL4ir3caZa0b%2Fuploads%2FJOhAgw1V7jkNc4ctBeRb%2FFIREBASE_IMAGE.png?alt=media&#x26;token=c30adbe3-8dd9-4306-930d-817d136fab39" alt=""><figcaption></figcaption></figure>

### 4.5.1 Create Firebase Project

1. First, you need to go to Firebase consoles [***https://firebase.google.com/***](https://firebase.google.com/) as shown in the image below.

<figure><img src="https://756612007-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfAZK2jZ3mL4ir3caZa0b%2Fuploads%2FkT1m9KJRYJHB8eJQ82Mr%2Ffirebase1.png?alt=media&#x26;token=fe352d5c-6ce5-403a-a99b-528859b39460" alt=""><figcaption></figcaption></figure>

2. Thereafter, click on ‘**Add Project**’ to create a new project.

<figure><img src="https://756612007-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfAZK2jZ3mL4ir3caZa0b%2Fuploads%2FTf5kzconAq4U77vy8sZL%2Ffirebase2.png?alt=media&#x26;token=6e942a5f-46c9-4d6c-bcbf-8ab1344e479a" alt=""><figcaption></figcaption></figure>

3. Enter the name of your project and click on continue.

<figure><img src="https://756612007-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfAZK2jZ3mL4ir3caZa0b%2Fuploads%2FQ7Y3ucrCfEMiTOFISXyq%2Ffirebase3.png?alt=media&#x26;token=b12ceb5c-6fb2-49c5-9891-1dc02a957ed7" alt=""><figcaption></figcaption></figure>

4. In this step, if you have enabled Google Analytics, then select an account for Google Analytics by clicking on ‘**Continue**’ and following that, click on the ‘**Create Project**’ button. If Google Analytics is disabled, then directly click on ‘**Create Project**’. It is not necessary to enable Google Analytics for our product.

<figure><img src="https://756612007-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfAZK2jZ3mL4ir3caZa0b%2Fuploads%2FsePAyGOFkKKerBeCqzO3%2Ffirebase4.png?alt=media&#x26;token=367b9c79-00d7-4f1b-86e0-c9167bd259fb" alt=""><figcaption></figcaption></figure>

### 4.5.2 Setup Firebase & Admin SDK

1. After creating the project, click on ‘**Project Settings**’ as shown in the image below.

<figure><img src="https://756612007-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfAZK2jZ3mL4ir3caZa0b%2Fuploads%2FYv9CB1XhTqIFx022GWQR%2Ffirebase5.png?alt=media&#x26;token=525c706b-71ff-41c0-ae90-1b4048588e12" alt=""><figcaption></figcaption></figure>

2. Click on ‘**\</>**’ ‘**Web app create**’ button as shown in the image below.

<figure><img src="https://756612007-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfAZK2jZ3mL4ir3caZa0b%2Fuploads%2FyJfbisEBHvfa1XXlpdvf%2Ffirebase6.png?alt=media&#x26;token=c0ca97b2-a98b-4a48-8aed-6a39566b20fa" alt=""><figcaption></figcaption></figure>

3. Enter the name of your Web App as shown in the image below and click on the ‘**Register app**’ button.

<figure><img src="https://756612007-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfAZK2jZ3mL4ir3caZa0b%2Fuploads%2FTQ2FAZSHdHJ0tRjenMeV%2Ffirebase7.png?alt=media&#x26;token=881137a1-13bd-45fa-8004-32c13599cf9c" alt=""><figcaption></figcaption></figure>

4. Now, you need to Get Firebase credentials. Add these credentials in the form field as shown in the example below.\
   \ <mark style="color:red;">**APIKEY = "apiKey\_get\_from\_firebaseConfig"**</mark>

   <mark style="color:red;">**AUTODOMAIN = "authdonain\_get\_from\_firebaseConfig"**</mark>

   <mark style="color:red;">**PROJECTID = "projectId\_get\_from\_firebaseConfig"**</mark>

   <mark style="color:red;">**STORAGEBUCKET ="storageBucket\_get\_from\_firebaseConfig"**</mark>

   <mark style="color:red;">**MESSAGINGSENDERID ="messagingSenderId\_get\_from\_firebaseConfig"**</mark>

   <mark style="color:red;">**APPID = "appId\_get\_from\_firebaseConfig"**</mark>

   <mark style="color:red;">**MEASUREMENTID = 'add\_if\_get\_from\_firebaseConfig'**</mark>

   <mark style="color:red;">**otherwise\_add=""(empty string)**</mark><br>
5. Now, click on the ‘**Continue to Console**’ button.<br>

   <figure><img src="https://756612007-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfAZK2jZ3mL4ir3caZa0b%2Fuploads%2FZqsYYt4EPfXWnVVGpgyz%2Ffirebase8.png?alt=media&#x26;token=90f7ea99-8b38-4c41-b557-191f3a437ab5" alt=""><figcaption></figcaption></figure>
6. Thereafter, click on service accounts as shown in the image below.

<figure><img src="https://756612007-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfAZK2jZ3mL4ir3caZa0b%2Fuploads%2FAN2SZoXctKAIEiCI1iEs%2Ffirebase9.png?alt=media&#x26;token=475cda32-fe13-4adb-a73b-99bf7111bc0c" alt=""><figcaption></figcaption></figure>

7. Click on the ‘**Generate New Private Key**’ button. It downloads one JSON file. Now copy that JSON file and paste it into <mark style="color:red;">**firebase-adminsdk.json**</mark> file which is in the root folder of your code.

<figure><img src="https://756612007-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfAZK2jZ3mL4ir3caZa0b%2Fuploads%2FSTjWkV0osXnQZLlP8XYm%2Ffirebase_admin_sdk.png?alt=media&#x26;token=3530fe35-9651-4102-bd64-6bbb6a871e8c" alt=""><figcaption></figcaption></figure>

### 4.5.3 Setup FCM SERVER KEY

1. In Project Settings, go to the ‘**Cloud Messaging**’ tab. Now, click on the 3 dots in the ‘**Cloud Messaging API**’ section and click on the ‘**Manage API in Google Cloud Console**’ option.

<figure><img src="https://756612007-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfAZK2jZ3mL4ir3caZa0b%2Fuploads%2F6oXzs8IWzj7aniTK0Ld2%2Ffirebase12.png?alt=media&#x26;token=6a164389-832e-4f3a-89cb-d03a9bf9bd9f" alt=""><figcaption></figcaption></figure>

2. Enable ‘**Cloud Messaging**’ as shown in the image below.

<figure><img src="https://756612007-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfAZK2jZ3mL4ir3caZa0b%2Fuploads%2FVUvn5PhLxPi8b9pPUDMd%2Ffirebase13.png?alt=media&#x26;token=3109bbb7-df04-4eff-8456-e634fb6ec52d" alt=""><figcaption></figcaption></figure>

3. Thereafter, search for the `Firebase Cloud Messaging Data API`, and enable it.

<figure><img src="https://756612007-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfAZK2jZ3mL4ir3caZa0b%2Fuploads%2FgldahYfERCxLrZxoevnU%2FFCM_IMAGE.png?alt=media&#x26;token=bd3671ad-aa72-483e-b4db-75526c940258" alt=""><figcaption></figcaption></figure>
