Backend Integration
Firebase Extension

Firebase Extension

Before you begin 📝

  • Make sure you have added Firebase to your project (opens in a new tab). If not, follow the steps in the link to get started.👍

  • Upgrade your project to the Blaze (pay as you go) plan if you haven't already. This is required for using Firebase extension (opens in a new tab).💸

  • Install or update to the latest version of the Firebase CLI. (opens in a new tab) This will let you install and manage Firebase extensions from the command line.👩‍💻

  • Make sure Cloud Storage is Enabled for your project, You can make sure that it's enabled from this link : https://console.cloud.google.com/apis/api/firestore.googleapis.com/overview (opens in a new tab)

  • Check if your Firestore database API is enabled and verify the necessary permissions, follow these steps:

    • Go to the Firestore section in your Firebase project.
    • Click on Firestore database in the left-hand side build dropdown menu.
    • If you can see your database, consider your API to be enabled.
    • Otherwise , click on the "Create database" button and configure it with your preferred options. This will automatically enable the API.
  • Ensure that your service account has the required permissions:

    • Go to the IAM (Identity and Access Management) section in the Cloud Console.
    • Click on "View by roles."
    • Check if the "Firebase Admin SDK Administrator Service Agent" role has a service account with a name similar to firebase-adminsdk-@<project_id>.iam.gserviceaccount.com. The service account should have the exact project ID as your Firebase project.
  • Additionally, verify the App Engine settings for your project:

    • Check the App Engine Settings page to ensure it is not disabled for your project.
    • App Engine is required to run Firestore DB, so make sure it is enabled.
  • By following these steps and ensuring the API is enabled, permissions are correctly set, and App Engine is enabled, you can ensure smooth access and operation of your Firestore database.

  • Find out either your Firebase project ID or previously configured project alias. You will need this to install the extension.

    • Project ID (opens in a new tab) — You can run this command from anywhere on your computer to see a list of your Firebase projects and their IDs.🔎
      firebase projects:list
    • Project alias (opens in a new tab) — You can run this command from your local app directory to see which alias you have set for your project.🔖
      firebase projects:list
  • Go to justpass.me Dashboard and copy these keys. You will need them to configure the extension.🔑

    • JUSTPASSME_ORGANIZATION_NAME
    • JUSTPASSME_ID
    • JUSTPASSME_API_SECRET

Install extension 🛠️

Development

  1. Run the following command
firebase init
  1. Choose Extensions: Set up an empty Extensions manifest

  2. run the following command

firebase ext:install justpass-me/justpass-me --project=projectId-or-alias

Deploy 🚢

To deploy the extension, run this command.

firebase deploy --only extensions 

Finalizing Installation

Grant the Authentication Permissions for the extension

The "Service Account Token Creator" IAM roles need to be granted to the service account ext-justpass-me@{project-name}.iam.gserviceaccount.com running the extension.

  1. Open the IAM-admin (opens in a new tab) page in the Google Cloud Console.
  2. Select your project and click "Continue".
  3. Click the edit icon corresponding to the service account you wish to update.
  4. Click on "Add Another Role".
  5. Type "Service Account Token Creator" into the search filter, and select it from the results.
  6. Click "Save" to confirm the role grant.

Monitorting

As a best practice, you can monitor the activity (opens in a new tab) of your installed extension, including checks on its health, usage, and logs.


2024 © justpass.me