Docs/Identity platform

Identity Platform

The Google Cloud Identity Platform (Firebase Auth)

is a that automatically imports and keeps your users up-to-date in UserHub.

To enable the Identity Platform connection, you need to upload your service account to UserHub.

Generate service account key

  1. Go to the Firebase Console
  2. Select the project you want to set up in UserHub
  3. Click the gear icon to the right of Project Overview
  4. Click Project settings
  5. Click the Service accounts tab
  6. Click the Generate new private key button

This will download a Google service account file. Make note of the location of the file; it will be used in the next step.

Note: You can create a more restricted service account. Use your existing process to provision a service account, generate a key, and assign the service account the roles/firebaseauth.admin role.

Set up connection

Next, you'll need to set up the

in UserHub.

  1. Go to the and click Connections via the Developers dropdown or Tenant settings
  2. Click Setup for Identity Platform
  3. Click the Browse button under Google service account file
  4. Select the file downloaded in the previous section (e.g. demo-firebase-adminsdk-kmv0h-53gajc255c.json)
  5. Click Save
  6. Make sure the status switches to Active.

Set up Portal callback

Next, you'll need to implement the Portal callback handler to allow users linked directly to the UserHub

to sign in.

Set up sign-up syncing

Setting up a function ensures your users are immediately pushed to UserHub when they sign up.

To set up a function, you'll need the UserHub Identity Platform connection ID (see above) and an

key scoped to Identity Platform.

Alternatively, you have the option of calling report event directly from your app.

Create API key

  1. Go to the and click API keys via the Developers dropdown or Tenant settings
  2. Click New API key
  3. Enter Identity Platform hook for the Description
  4. Select Admin API for the Type
  5. Don't set an expiration
  6. Click the Integrations dropdown and select Identity Platform
  7. Click Create
  8. Note the generated API key (e.g. userhub_admin_agX...), as this token will be used in the next step

Set up function

Next, you'll need to set up the function in Firebase:

  1. Ensure you have the Firebase CLI installed, authenticated, and your project initialized

  2. Ensure functions are initialized in your project

    firebase init functions
    
  3. Add the following code to your functions file (e.g. functions/index.js):

    const { auth, logger } = require("firebase-functions/v1");
    const { defineSecret, defineString } = require("firebase-functions/params");
    
    const baseUrl = "https://api.userhub.com";
    const adminKey = defineSecret("USERHUB_ADMIN_KEY");
    const connectionId = defineString("IDENTITY_PLATFORM_CONNECTION_ID");
    
    exports.onCreate = auth.user().onCreate(async (user) => {
       try {
        const userId = encodeURIComponent(user.uid);
    
        const response = await fetch(
          `${baseUrl}/admin/v1/users/${userId}@${connectionId}:event`,
          {
            method: "POST",
            headers: {
              authorization: `Bearer ${adminKey.value()}`,
              "user-agent": "UserHub-FirebaseAuth/1.0",
            },
            data: JSON.stringify({ type: "SIGNUP" }),
            signal: AbortSignal.timeout(2 * 1000),
          },
        );
        if (!response.ok) {
          throw new Error(`${response.status}: ${await response.text()}`);
        }
      } catch (e) {
        logger.error(`Failed to report signup to UserHub: ${e}`);
      }
    });
    
  4. Deploy the function and enter the variables when prompted:

    firebase deploy --only functions
    
PreviousFirebase Auth
NextStripe

Build software thatmonetizes
$

Subscribe to monthly product updates

© 2025 UserHub

Integrations

    UserHub & Auth0UserHub & Stripe BillingUserHub & Google CloudUserHub & FirebaseUserHub & custom auth