# Connect With Admin

## ![](https://docs.pixelstrap.net/laravel/taxido/assets/images/icons/firebase.png)**Connect With Admin :**

{% hint style="danger" %} <mark style="color:red;">**Note :**</mark> <mark style="color:red;">Our app requires a billing account to function. Please ensure you set appropriate daily or usage limits on your billing account for safety.</mark>\ <mark style="color:red;">If the API key is overused, misused, or exposed, and this results in high charges, we will not be responsible for any billing costs. Managing limits and securing keys is the user’s responsibility.</mark>
{% endhint %}

{% hint style="warning" %} <i class="fa-bullhorn">:bullhorn:</i> NOTE :Before launching the app, ensure you have correctly set up the ADMIN LARAVEL and have added all necessary data through the admin panel.
{% endhint %}

As you have know there are multiple collection has been used in firebase. Let's see what is the use of the collection and how it added

**There are 5 collections created in the firebase**<br>

1. chats - \[Auto generate]
2. driverTrack - \[Auto generate]
3. driver\_ride\_requests - \[Auto generate]
4. ride\_requests - \[Auto generate]
5. rides - \[Auto generate]
6. users - \[Auto generate]\ <br>

   <div align="left"><figure><img src="https://docs.pixelstrap.net/laravel/taxido/assets/images/laravelApi/taxido/collection.png" alt=""><figcaption></figcaption></figure></div>

{% hint style="warning" %} <i class="fa-bullhorn">:bullhorn:</i> NOTE :\
In above collection list \[Auto generate] means this collections are generate in firebase whenever any first user enter any data
{% endhint %}

1. Now go to Service accounts\
   \
   To get the <mark style="color:$danger;">`firebase.json`</mark> file, just follow the steps below.

2. Go to [Firebase Console](https://console.firebase.google.com/)<br>

   <figure><img src="https://74030740-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6o4UzjBZtMQpeq4oeh8s%2Fuploads%2FXMy0AXcAeYz0giV4R8Ek%2Fimage.png?alt=media&#x26;token=933bff48-2e25-470f-83fe-89acac1c7a64" alt=""><figcaption></figcaption></figure>

3. Now go to your Firebase project, On left hand side panel click on setting icon. On click Setting button pop open. In that click on Project Settings\
   \
   \
   ![](https://74030740-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6o4UzjBZtMQpeq4oeh8s%2Fuploads%2FHHZt9lLPZQeSvECqWXzR%2Fimage.png?alt=media\&token=a98d34c3-644b-41a0-afcc-1956202c41d0)<br>

4. Now go to Service accounts<br>

   <figure><img src="https://74030740-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6o4UzjBZtMQpeq4oeh8s%2Fuploads%2FGAP87wJJBhxPKTSBtLcM%2Fimage.png?alt=media&#x26;token=67b06ce4-de9f-4dfe-9e8a-e06afad03b23" alt=""><figcaption></figcaption></figure>

5. Now click on button Generate new private key<br>

   <figure><img src="https://74030740-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6o4UzjBZtMQpeq4oeh8s%2Fuploads%2F4V2TYLqFXqCr13AX1TYt%2Fimage.png?alt=media&#x26;token=85fc54cc-6388-4a82-ba7c-ebba47928df1" alt=""><figcaption></figcaption></figure>

6. After click on button on pop-up appear int that click on Generate key

<div align="center" data-full-width="true"><figure><img src="https://74030740-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6o4UzjBZtMQpeq4oeh8s%2Fuploads%2Ffl1bxqXLFffXbaANbL01%2Fimage.png?alt=media&#x26;token=1a95a812-f547-48db-9717-a91c7b495ff0" alt="" width="563"><figcaption></figcaption></figure></div>

<figure><img src="https://74030740-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6o4UzjBZtMQpeq4oeh8s%2Fuploads%2FeLOz6my9seOrfW3dx97Z%2Fimage.png?alt=media&#x26;token=fa1759e2-ecfb-429d-bbc1-d720baea84ca" alt=""><figcaption></figcaption></figure>

Once uploaded, the file will be saved to: `public/admin/assets/firebase.json`. The system will use this file for Firebase Admin SDK integration.

### **Connect Admin with Firebase**

<figure><img src="https://74030740-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6o4UzjBZtMQpeq4oeh8s%2Fuploads%2Fa4Fz6KPdAVzfid2MdhIC%2Fimage.png?alt=media&#x26;token=5ca80305-f1bc-4fa2-b227-6db31d8dce6b" alt=""><figcaption></figcaption></figure>

#### Firebase Console → Project Settings → General → Web API Key

<figure><img src="https://74030740-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6o4UzjBZtMQpeq4oeh8s%2Fuploads%2FhBgEVGZqLDaN3QCcIyVZ%2Fimage.png?alt=media&#x26;token=722fd754-718b-47d1-a036-9c865a0cfbb6" alt=""><figcaption></figcaption></figure>

* **Firebase API Key:** Used to identify your Firebase project when using client-side SDKs.\
  \&#xNAN;*Find it in:* Firebase Console → Project Settings → General → Web API Key
* **Firebase Auth Domain:** Domain used for Firebase Authentication (usually ends with `.firebaseapp.com`).\
  \&#xNAN;*Find it in:* Firebase config JSON → `authDomain`
* **Firebase Database URL:** URL to access your Firebase Realtime Database.\
  \&#xNAN;*Find it in:* Firebase Console → Realtime Database → Database URL
* **Firebase Storage Bucket:** Used to store user files like images or documents.\
  \&#xNAN;*Find it in:* Firebase config JSON → `storageBucket`
* **Firebase Messaging Sender ID:** Unique ID used for Firebase Cloud Messaging (push notifications).\
  \&#xNAN;*Find it in:* Firebase config JSON → `messagingSenderId`
* **Firebase App ID:** Unique identifier for your application registered with Firebase.\
  \&#xNAN;*Find it in:* Firebase config JSON → `appId`
* **Firebase Measurement ID:** Used for integrating with Google Analytics (optional).\
  \&#xNAN;*Find it in:* Firebase config JSON → `measurementId`\
  \
  \
  \
  \ <br>

{% hint style="info" %} <mark style="color:blue;">These details are stored in the</mark> <mark style="color:blue;"></mark><mark style="color:blue;">`firebase.json`</mark> <mark style="color:blue;"></mark><mark style="color:blue;">file, which is saved at</mark> <mark style="color:blue;"></mark><mark style="color:blue;">**public/admin/assets/firebase.json**</mark><mark style="color:blue;">. Any additional Firebase-related keys or configuration added from the admin panel are stored in the</mark> <mark style="color:blue;"></mark><mark style="color:blue;">`.env`</mark> <mark style="color:blue;"></mark><mark style="color:blue;">file.</mark>
{% endhint %}

### <img src="https://docs.pixelstrap.net/laravel/taxido/assets/images/icons/cloudFirestore.png" alt="Firebase Icon" data-size="line">**Firebase SMS Authentication**

**Firebase SMS Authentication:** Allows users to log in using their mobile number via Firebase's OTP (One-Time Password) authentication system.

**Login Flow:**

* User visits the login page and enters their mobile number.
* On clicking **"Send OTP"**, Firebase sends a verification code via SMS.
* The user enters the OTP in the input fields and clicks **"Verify"**.
* Upon successful verification:
  * If the number already exists in Firebase, the user is logged in directly.
  * **If the number is not registered:** the user is redirected to a manual registration form to fill in details like name, email, etc.
* The Firebase UID and access token are stored in your backend for future logins.

<figure><img src="https://74030740-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6o4UzjBZtMQpeq4oeh8s%2Fuploads%2FMztwYNBTHGdBV35uaoJK%2Fimage.png?alt=media&#x26;token=a5ec2de0-a025-49c5-93dd-2de12b0aea8d" alt=""><figcaption></figcaption></figure>

<figure><img src="https://74030740-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6o4UzjBZtMQpeq4oeh8s%2Fuploads%2FNx2Rse6JPhhQTAWGzEdE%2Fimage.png?alt=media&#x26;token=a79d7ae6-3de3-49b1-8c71-e9d6c6c5865d" alt=""><figcaption></figcaption></figure>

{% hint style="info" %} <mark style="color:blue;">**Note:**</mark> <mark style="color:blue;"></mark><mark style="color:blue;">This authentication method is secure and uses Firebase's built-in phone number verification with reCAPTCHA.</mark>
{% endhint %}

**Running Firebase Authentication Locally:**\
If you want to test Firebase SMS login locally, you must manually register your test phone number in your Firebase project. Follow the steps below:

1. Go to the **Authentication** tab in your Firebase project.

<figure><img src="https://docs.pixelstrap.net/laravel/taxido/assets/images/laravelApi/taxido/firebase-sms.png" alt=""><figcaption></figcaption></figure>

2. Click on the **Sign-in Method** section from the left sidebar.

<figure><img src="https://74030740-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6o4UzjBZtMQpeq4oeh8s%2Fuploads%2F8PzovJzggO9qvT5iBIeM%2Fimage.png?alt=media&#x26;token=b0a4931b-2054-47aa-b822-237626ce3ace" alt=""><figcaption></figcaption></figure>

3. Scroll down to the **Phone** provider and click the **Edit** icon (pencil button).

4. In the popup modal, register your test number by entering:

   * **Phone Number** (e.g., +91XXXXXXXXXX)
   * **Verification Code (OTP)** – any default code you'd like to use for local testing

   <div align="left"><figure><img src="https://docs.pixelstrap.net/laravel/taxido/assets/images/laravelApi/taxido/firebase-user.png" alt=""><figcaption></figcaption></figure></div>

5. Go to the **Authentication** tab in your Firebase project.

{% hint style="info" %} <mark style="color:blue;">**Note:**</mark> <mark style="color:blue;"></mark><mark style="color:blue;">These steps are only required for local development. On a live/production domain, Firebase will send actual OTPs to users automatically.</mark>
{% endhint %}

<figure><img src="https://docs.pixelstrap.net/laravel/taxido/assets/images/laravelApi/taxido/firebase-otp.png" alt=""><figcaption></figcaption></figure>

{% hint style="info" %} <mark style="color:blue;">**Note:**</mark> <mark style="color:blue;"></mark><mark style="color:blue;">This authentication method is secure and uses Firebase's built-in phone number verification with reCAPTCHA.</mark>
{% endhint %}

**Running Firebase Authentication Locally:**\
If you want to test Firebase SMS login locally, you must manually register your test phone number in your Firebase project. Follow the steps below:

**For Localhost assign test number and OTP**

1. Go to the **Authentication** tab in your Firebase project.

<figure><img src="https://docs.pixelstrap.net/laravel/taxido/assets/images/laravelApi/taxido/firebase-sms.png" alt=""><figcaption></figcaption></figure>

2. Click on the **Sign-in Method** section from the left sidebar.

<figure><img src="https://docs.pixelstrap.net/laravel/taxido/assets/images/laravelApi/taxido/firebase1.png" alt=""><figcaption></figcaption></figure>

3. Scroll down to the **Phone** provider and click the **Edit** icon (pencil button).

4. In the popup modal, register your test number by entering:

   * **Phone Number** (e.g., +91XXXXXXXXXX)
   * **Verification Code (OTP)** – any default code you'd like to use for local testing

   <figure><img src="https://docs.pixelstrap.net/laravel/taxido/assets/images/laravelApi/taxido/firebase-user.png" alt=""><figcaption></figcaption></figure>

5. Click **Save**. This number is now allowed to receive a default OTP during local development without needing real SMS delivery.

{% hint style="info" %} <mark style="color:blue;">**Note:**</mark> <mark style="color:blue;"></mark><mark style="color:blue;">These steps are only required for local development. On a live/production domain, Firebase will send actual OTPs to users automatically.</mark><br>
{% endhint %}

{% hint style="warning" %}
**Testing Note:** You can test this login/registration flow on the production domain, where SMS login and new user handling work automatically.\
\
For local testing, ensure the test phone number is manually registered in Firebase. On production, this registration happens automatically during login.
{% endhint %}

{% hint style="info" %} <mark style="color:blue;">**Note:**</mark> <mark style="color:blue;"></mark><mark style="color:blue;">These steps are only necessary for local development. For a live or production domain, you need to connect the domain to Firebase as outlined in the steps below.</mark>
{% endhint %}

**Running Firebase Authentication in Live Production Server:**\
These steps are intended for setting up Firebase Authentication using phone login on a live server in a production environment. Ensure you have administrative access to your Firebase project and the domain you intend to authorize. Misconfiguration may lead to authentication failures or security issues, so proceed with caution and double-check each step.

1. Go to the **Authentication** tab in your Firebase project.
2. Go to the Settings Tab

   In the Authentication dashboard, click on the Settings tab at the top (next to "Users", "Sign-in method", etc.).
3. Locate the Authorized Domains Section

   Scroll down to the Authorized domains section. This section lists domains that are allowed for OAuth redirects, which are required for phone authentication.
4. Add Your Domain

   Click the Add domain button (as shown in the screenshot).

   In the pop-up, enter your production domain (e.g., myapp.com)

{% hint style="warning" %}
**Important:** Do not include http\:// or https\://, and do not add a trailing slash. For example, use myapp.com, not <https://myapp.com/>.
{% endhint %}

<figure><img src="https://74030740-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6o4UzjBZtMQpeq4oeh8s%2Fuploads%2FS0lQjrXA7sAJuGPfB8Wt%2Fimage.png?alt=media&#x26;token=473ebb45-f5da-45d5-9e25-0569c101214a" alt=""><figcaption></figcaption></figure>
