firebase_admin.phone_number_verification module

Firebase Phone Number Verification module.

This module contains functions for verifying JWTs related to the Firebase Phone Number Verification service.

Exceptions

ExpiredTokenError

exception firebase_admin.phone_number_verification.ExpiredTokenError(message, cause=None, http_response=None)

Bases: InvalidTokenError

Raised when a Firebase Phone Number Verification token is expired.

InvalidTokenError

exception firebase_admin.phone_number_verification.InvalidTokenError(message, cause=None, http_response=None)

Bases: InvalidArgumentError

Raised when a Firebase Phone Number Verification token is invalid.

Classes

PhoneNumberVerificationToken

class firebase_admin.phone_number_verification.PhoneNumberVerificationToken(claims)

Bases: dict

Represents a verified Firebase Phone Number Verification token.

This class behaves like a dictionary, allowing access to the decoded claims. It also provides convenience properties for common claims.

property audience: str

Returns the audience for which this token is intended.

property claims

Returns the entire map of claims.

property exp: int

Returns the expiration time since the Unix epoch.

property iat: int

Returns the issued-at time since the Unix epoch.

property issuer: str

Returns the issuer identifier for the issuer of the response.

property phone_number: str

Returns the phone number of the user. This corresponds to the ‘sub’ claim in the JWT.

property sub: str

Returns the sub (subject) of the token, which is the phone number.

Functions

verify_token

firebase_admin.phone_number_verification.verify_token(token: str, app: App | None = None) PhoneNumberVerificationToken

Verifies a Firebase Phone Number Verification token.

Parameters:
  • token – A string containing the Firebase Phone Number Verification JWT.

  • app – An App instance (optional).

Returns:

The verified token claims.

Return type:

PhoneNumberVerificationToken

Raises: