Google is committed to advancing racial equity for Black communities. See how.

MultiFactor

public abstract class MultiFactor extends Object

Defines multi-factor related properties and operations pertaining to a FirebaseUser. 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.

Public Constructor Summary

Public Method Summary

abstract Task<Void>
enroll(MultiFactorAssertion multiFactorAssertion, String displayName)
Enrolls a second factor as identified by the MultiFactorAssertion parameter for the current user.
abstract List<MultiFactorInfo>
getEnrolledFactors()
Returns a list of the MultiFactorInfo already associated with this user.
abstract Task<MultiFactorSession>
getSession()
Returns a session identifier for a second factor enrollment operation.
abstract Task<Void>
unenroll(String factorUid)
Unenrolls a second factor from this user.
abstract Task<Void>
unenroll(MultiFactorInfo multiFactorInfo)
Unenrolls a second factor from this user.

Inherited Method Summary

Public Constructors

public MultiFactor ()

Public Methods

public abstract Task<Void> enroll (MultiFactorAssertion multiFactorAssertion, String displayName)

Enrolls a second factor as identified by the MultiFactorAssertion 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.

A MultiFactorAssertion can be generated using getAssertion(PhoneAuthCredential) for enrolling your phone number as a second factor.

Parameters
multiFactorAssertion the assertion representing the second factor to enroll
displayName an optional name for identifying this second factor

public abstract List<MultiFactorInfo> getEnrolledFactors ()

Returns a list of the MultiFactorInfo already associated with this user.

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

public abstract Task<MultiFactorSession> getSession ()

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 a PhoneAuthOptions instance to call verifyPhoneNumber(PhoneAuthOptions) for enrollment.

public abstract Task<Void> unenroll (String factorUid)

Unenrolls a second factor from this user.

The factorUid to be passed in can be retrieved from getEnrolledFactors().

public abstract Task<Void> unenroll (MultiFactorInfo multiFactorInfo)

Unenrolls a second factor from this user.

The MultiFactorInfo to be passed in can be gotten from getEnrolledFactors().