MultiFactor

abstract classMultiFactor


Defines multi-factor related properties and operations pertaining to aFirebaseUser. This class acts as the main entry point for enrolling or un-enrolling second factors for a user, and provides access to their currently enrolled factors.

Summary

Public constructors

Public functions

abstractTask<Void!>
enroll(multiFactorAssertion: MultiFactorAssertion, displayName: String?)

Enrolls a second factor as identified by theMultiFactorAssertion parameter for the current user.

abstract (Mutable)List<MultiFactorInfo!>

Returns a list of theMultiFactorInfo already associated with this user.

abstractTask<MultiFactorSession!>

Returns a session identifier for a second factor enrollment operation.

abstractTask<Void!>
unenroll(factorUid: String)

Unenrolls a second factor from this user.

abstractTask<Void!>
unenroll(multiFactorInfo: MultiFactorInfo)

Unenrolls a second factor from this user.

Public constructors

MultiFactor

MultiFactor()

Public functions

enroll

abstract fun enroll(multiFactorAssertion: MultiFactorAssertion, displayName: String?): Task<Void!>

Enrolls a second factor as identified by theMultiFactorAssertion parameter for the current user.

On successful enrollment, existing Firebase sessions are revoked, and an email notification is sent to the user’s email. The user's must have a verified email to enroll a second factor.

AMultiFactorAssertion can be generated usinggetAssertion for enrolling phone number as a second factor orgetAssertionForEnrollment for enrolling TOTP as a second factor.

Parameters
multiFactorAssertion: MultiFactorAssertion

the assertion representing the second factor to enroll

displayName: String?

an optional name for identifying this second factor

getEnrolledFactors

abstract fun getEnrolledFactors(): (Mutable)List<MultiFactorInfo!>

Returns a list of theMultiFactorInfo already associated with this user.

If the user does not have any enrolled factors, the list will be empty.

getSession

abstract fun getSession(): Task<MultiFactorSession!>

Returns a session identifier for a second factor enrollment operation. This is used to identify the current user trying to enroll a second factor.

To be used when building aPhoneAuthOptions instance to callverifyPhoneNumber for phone factor enrollment, or when generating aTotpSecret instance for TOTP factor enrollment.

unenroll

abstract fun unenroll(factorUid: String): Task<Void!>

Unenrolls a second factor from this user.

ThefactorUid to be passed in can be retrieved fromgetEnrolledFactors.

unenroll

abstract fun unenroll(multiFactorInfo: MultiFactorInfo): Task<Void!>

Unenrolls a second factor from this user.

TheMultiFactorInfo to be passed in can be gotten fromgetEnrolledFactors.

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-07-21 UTC.