firebase_admin.tenant_mgt module

Firebase tenant management module.

This module contains functions for creating and configuring authentication tenants within aGoogle Cloud Identity Platform (GCIP) instance.

Exceptions

TenantIdMismatchError

exceptionfirebase_admin.tenant_mgt.TenantIdMismatchError(message)

Bases:InvalidArgumentError

Missing or invalid tenant ID field in the given JWT.

TenantNotFoundError

exceptionfirebase_admin.tenant_mgt.TenantNotFoundError(message,cause=None,http_response=None)

Bases:NotFoundError

No tenant found for the specified identifier.

default_message='Notenantfoundforthegivenidentifier'

Classes

ListTenantsPage

classfirebase_admin.tenant_mgt.ListTenantsPage(download,page_token,max_results)

Bases:object

Represents a page of tenants fetched from a Firebase project.

Provides methods for traversing tenants included in this page, as well as retrievingsubsequent pages of tenants. The iterator returned byiterate_all() can be used to iteratethrough all tenants in the Firebase project starting from this page.

get_next_page()

Retrieves the next page of tenants, if available.

Returns:

Next page of tenants, or None if this is the last page.

Return type:

ListTenantsPage

iterate_all()

Retrieves an iterator for tenants.

Returned iterator will iterate through all the tenants in the Firebase projectstarting from this page. The iterator will never buffer more than one page of tenantsin memory at a time.

Returns:

An iterator of Tenant instances.

Return type:

iterator

propertyhas_next_page

A boolean indicating whether more pages are available.

propertynext_page_token

Page token string for the next page (empty string indicates no more pages).

propertytenants

A list ofExportedUserRecord instances available in this page.

Tenant

classfirebase_admin.tenant_mgt.Tenant(data)

Bases:object

Represents a tenant in a multi-tenant application.

Multi-tenancy support requires Google Cloud Identity Platform (GCIP). To learn more aboutGCIP including pricing and features, seehttps://cloud.google.com/identity-platform.

Before multi-tenancy can be used in a Google Cloud Identity Platform project, tenants must beenabled in that project via the Cloud Console UI. A Tenant instance provides informationsuch as the display name, tenant identifier and email authentication configuration.

propertyallow_password_sign_up
propertydisplay_name
propertyenable_email_link_sign_in
propertytenant_id

Functions

auth_for_tenant

firebase_admin.tenant_mgt.auth_for_tenant(tenant_id,app=None)

Gets an Auth Client instance scoped to the given tenant ID.

Parameters:
  • tenant_id – A tenant ID string.

  • app – An App instance (optional).

Returns:

Anauth.Client object.

Return type:

auth.Client

Raises:

ValueError – If the tenant ID is None, empty or not a string.

create_tenant

firebase_admin.tenant_mgt.create_tenant(display_name,allow_password_sign_up=None,enable_email_link_sign_in=None,app=None)

Creates a new tenant from the given options.

Parameters:
  • display_name – Display name string for the new tenant. Must begin with a letter and containonly letters, digits and hyphens. Length must be between 4 and 20.

  • allow_password_sign_up – A boolean indicating whether to enable or disable the email sign-inprovider (optional).

  • enable_email_link_sign_in – A boolean indicating whether to enable or disable email linksign-in (optional). Disabling this makes the password required for email sign-in.

  • app – An App instance (optional).

Returns:

A tenant object.

Return type:

Tenant

Raises:
  • ValueError – If any of the given arguments are invalid.

  • FirebaseError – If an error occurs while creating the tenant.

delete_tenant

firebase_admin.tenant_mgt.delete_tenant(tenant_id,app=None)

Deletes the tenant corresponding to the giventenant_id.

Parameters:
  • tenant_id – A tenant ID string.

  • app – An App instance (optional).

Raises:
  • ValueError – If the tenant ID is None, empty or not a string.

  • TenantNotFoundError – If no tenant exists by the given ID.

  • FirebaseError – If an error occurs while retrieving the tenant.

get_tenant

firebase_admin.tenant_mgt.get_tenant(tenant_id,app=None)

Gets the tenant corresponding to the giventenant_id.

Parameters:
  • tenant_id – A tenant ID string.

  • app – An App instance (optional).

Returns:

A tenant object.

Return type:

Tenant

Raises:
  • ValueError – If the tenant ID is None, empty or not a string.

  • TenantNotFoundError – If no tenant exists by the given ID.

  • FirebaseError – If an error occurs while retrieving the tenant.

list_tenants

firebase_admin.tenant_mgt.list_tenants(page_token=None,max_results=100,app=None)

Retrieves a page of tenants from a Firebase project.

Thepage_token argument governs the starting point of the page. Themax_resultsargument governs the maximum number of tenants that may be included in the returned page.This function never returns None. If there are no user accounts in the Firebase project, thisreturns an empty page.

Parameters:
  • page_token – A non-empty page token string, which indicates the starting point of the page(optional). Defaults toNone, which will retrieve the first page of users.

  • max_results – A positive integer indicating the maximum number of users to include in thereturned page (optional). Defaults to 100, which is also the maximum number allowed.

  • app – An App instance (optional).

Returns:

A page of tenants.

Return type:

ListTenantsPage

Raises:
  • ValueError – Ifmax_results orpage_token are invalid.

  • FirebaseError – If an error occurs while retrieving the user accounts.

update_tenant

firebase_admin.tenant_mgt.update_tenant(tenant_id,display_name=None,allow_password_sign_up=None,enable_email_link_sign_in=None,app=None)

Updates an existing tenant with the given options.

Parameters:
  • tenant_id – ID of the tenant to update.

  • display_name – Updated display name string for the tenant (optional).

  • allow_password_sign_up – A boolean indicating whether to enable or disable the email sign-inprovider.

  • enable_email_link_sign_in – A boolean indicating whether to enable or disable email linksign-in. Disabling this makes the password required for email sign-in.

  • app – An App instance (optional).

Returns:

The updated tenant object.

Return type:

Tenant

Raises:
  • ValueError – If any of the given arguments are invalid.

  • TenantNotFoundError – If no tenant exists by the given ID.

  • FirebaseError – If an error occurs while creating the tenant.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-03-12 UTC.