FirebaseUser

public abstract classFirebaseUser implementsParcelable,UserInfo


Represents a user's profile information in your Firebase project's user database. It also contains helper methods to change or retrieve profile information, as well as to manage that user's authentication state.

Summary

Public constructors

Public methods

@NonNullTask<Void>

Deletes the user record from your Firebase project's database.

abstract @NullableString

Returns the main display name of this user from the Firebase project's user database.

abstract @NullableString

Returns the main email address of the user, as stored in the Firebase project's user database.

@NonNullTask<GetTokenResult>
getIdToken(boolean forceRefresh)

Fetches a Firebase Auth ID Token for the user; useful when authenticating against your own backend.

abstract @NullableFirebaseUserMetadata

Returns theFirebaseUserMetadata associated with this user.

abstract @NonNullMultiFactor

Returns aMultiFactor instance which is the main entry point for multi-factor related operations on this user.

abstract @NullableString

Returns the phone number of the user, as stored in the Firebase project's user database, ornull if none exists.

abstract @NullableUri

Returns the URL of this user's main profile picture, as stored in the Firebase project's user database.

abstract @NonNullList<UserInfo>

Returns aList ofUserInfo objects that represents the linked identities of the user using different authentication providers that may be linked to their account.

abstract @NonNullString

Always returnsPROVIDER_ID.

abstract @NullableString

Returns the tenant ID of the current user ornull if this user isn't associated with a tenant project.

abstract @NonNullString

Returns a string used to uniquely identify your user in your Firebase project's user database.

abstract boolean

Returns true if the user is anonymous; that is, the user account was created withsignInAnonymously and has not been linked to another account withlinkWithCredential.

@NonNullTask<AuthResult>

Attaches the givenAuthCredential to the user.

@NonNullTask<Void>

Reauthenticates the user with the given credential.

@NonNullTask<AuthResult>

Reauthenticates the user with the given credential, and returns the profile data for that account.

@NonNullTask<Void>

Manually refreshes the data of the current user (for example, attached providers, display name, and so on).

@NonNullTask<Void>

CallssendEmailVerification with nullactionCodeSettings.

@NonNullTask<Void>

Initiates email verification for the user.

@NonNullTask<AuthResult>
startActivityForLinkWithProvider(
    @NonNullActivity activity,
    @NonNullFederatedAuthProvider federatedAuthProvider
)

Links the user using the mobile browser (either a Custom Chrome Tab or the device's default browser) to the givenprovider.

@NonNullTask<AuthResult>

Reauthenticates the user using the mobile browser (either a Custom Chrome Tab or the device's default browser) using the givenprovider.

@NonNullTask<AuthResult>
unlink(@NonNullString provider)

Detaches credentials from a given provider type from this user.

@NonNullTask<Void>

This method is deprecated.

UseverifyBeforeUpdateEmail instead.

@NonNullTask<Void>

Updates the password of the user.

@NonNullTask<Void>

Updates the phone number of the user.

@NonNullTask<Void>

Updates the user profile information.

@NonNullTask<Void>

CallsverifyBeforeUpdateEmail without anyactionCodeSettings.

@NonNullTask<Void>
verifyBeforeUpdateEmail(
    @NonNullString newEmail,
    @NullableActionCodeSettings actionCodeSettings
)

Sends a verification email tonewEmail.

Inherited Constants

Fromandroid.os.Parcelable
static final int
static final int

Inherited methods

Fromandroid.os.Parcelable
abstract int
abstract void
writeToParcel(Parcel p, int p1)
Fromcom.google.firebase.auth.UserInfo
abstract boolean

Returnstrue if the user's email is verified.

Public constructors

FirebaseUser

public FirebaseUser()

Public methods

delete

public @NonNullTask<Voiddelete()

Deletes the user record from your Firebase project's database. If the operation is successful, the user will be signed out.

Important: this is a security sensitive operation that requires the user to have recently signed in. If this requirement isn't met, ask the user to authenticate again and later callreauthenticate.

Exceptions

getDisplayName

public abstract @NullableString getDisplayName()

Returns the main display name of this user from the Firebase project's user database. Unlike the display name property from instances ofUserInfo corresponding to authentication providers (like Google Sign-In), which is not modifiable, this name can be updated at any time by callingupdateProfile.

This field will be automatically populated on account creation if theAuthCredential used onsignInWithCredential contained such information.

getEmail

public abstract @NullableString getEmail()

Returns the main email address of the user, as stored in the Firebase project's user database. Unlike the email property from instances ofUserInfo corresponding to authentication providers (like GitHub), which is not modifiable, this email address can be updated at any time by callingupdateEmail.

This field will be automatically populated on account creation if theAuthCredential used onsignInWithCredential contained such information, or if the account was created withcreateUserWithEmailAndPassword. However, this is not true if the setting "Multiple Accounts per Email" is enabled in the Firebase Console - in that case this will be null unless the account was created withcreateUserWithEmailAndPassword orupdateEmail has been called.

If the user also has a password, this email address can be used to sign in into the account usingsignInWithEmailAndPassword.

This email address is displayed in the Users section of the Firebase console.

See also
updateEmail

getIdToken

public @NonNullTask<GetTokenResultgetIdToken(boolean forceRefresh)

Fetches a Firebase Auth ID Token for the user; useful when authenticating against your own backend. Use our server SDKs or follow the official documentation to securely verify the integrity and validity of this token.

Exceptions
  • FirebaseAuthInvalidUserException ifforceRefresh == true, thrown if the current user's account has been disabled, deleted, or its credentials are no longer valid
Parameters
boolean forceRefresh

force refreshes the token. Should only be set totrue if the token is invalidated out of band.

getMetadata

public abstract @NullableFirebaseUserMetadata getMetadata()

Returns theFirebaseUserMetadata associated with this user.

getMultiFactor

public abstract @NonNullMultiFactor getMultiFactor()

Returns aMultiFactor instance which is the main entry point for multi-factor related operations on this user.

getPhoneNumber

public abstract @NullableString getPhoneNumber()

Returns the phone number of the user, as stored in the Firebase project's user database, ornull if none exists. This can be updated at any time by callingupdatePhoneNumber.

This field will be automatically populated on account creation if theAuthCredential used onsignInWithCredential contained such information. This phone number is displayed in the Users section of the Firebase console.

getPhotoUrl

public abstract @NullableUri getPhotoUrl()

Returns the URL of this user's main profile picture, as stored in the Firebase project's user database. Unlike the profile URL property from instances ofUserInfo corresponding to authentication providers (like Facebook Login), which is not modifiable, this URL can be updated at any time by callingupdateProfile.

This field will be automatically populated on account creation if theAuthCredential used onsignInWithCredential contained such information.

getProviderData

public abstract @NonNullList<UserInfogetProviderData()

Returns aList ofUserInfo objects that represents the linked identities of the user using different authentication providers that may be linked to their account. Use this to access, for example, your user's basic profile information retrieved from Facebook whether or not the user used Facebook Login to sign in to the current session.

getProviderId

public abstract @NonNullString getProviderId()

Always returnsPROVIDER_ID.

getTenantId

public abstract @NullableString getTenantId()

Returns the tenant ID of the current user ornull if this user isn't associated with a tenant project.

getUid

public abstract @NonNullString getUid()

Returns a string used to uniquely identify your user in your Firebase project's user database. Use it when storing information in Firebase Database or Storage, or even in your own backend.

This identifier is opaque and does not correspond necessarily to the user's email address or any other field.

isAnonymous

public abstract boolean isAnonymous()

Returns true if the user is anonymous; that is, the user account was created withsignInAnonymously and has not been linked to another account withlinkWithCredential.

linkWithCredential

public @NonNullTask<AuthResultlinkWithCredential(@NonNullAuthCredential credential)

Attaches the givenAuthCredential to the user. This allows the user to sign in to this account in the future with credentials for such provider.

Exceptions
Parameters
@NonNullAuthCredential credential

a valid credential of a type not yet linked to this user

reauthenticate

public @NonNullTask<Voidreauthenticate(@NonNullAuthCredential credential)

Reauthenticates the user with the given credential. This is useful for operations that require a recent sign-in, to prevent or resolve aFirebaseAuthRecentLoginRequiredException.

Exceptions
Parameters
@NonNullAuthCredential credential

authentication credential that must be valid for the current user.

reauthenticateAndRetrieveData

public @NonNullTask<AuthResultreauthenticateAndRetrieveData(@NonNullAuthCredential credential)

Reauthenticates the user with the given credential, and returns the profile data for that account. This is useful for operations that require a recent sign-in, to prevent or resolve aFirebaseAuthRecentLoginRequiredException.

Exceptions
Parameters
@NonNullAuthCredential credential

authentication credential that must be valid for the current user.

Returns
@NonNullTask<AuthResult>

AuthResult containing theFirebaseUser reference and .

reload

public @NonNullTask<Voidreload()

Manually refreshes the data of the current user (for example, attached providers, display name, and so on).

Exceptions

sendEmailVerification

public @NonNullTask<VoidsendEmailVerification()

CallssendEmailVerification with nullactionCodeSettings.

sendEmailVerification

public @NonNullTask<VoidsendEmailVerification(@NonNullActionCodeSettings actionCodeSettings)

Initiates email verification for the user. Takes in anActionCodeSettings to allow linking back to your app in the email.

Returns
@NonNullTask<Void>

Task to track completion of the sending operation.

startActivityForLinkWithProvider

public @NonNullTask<AuthResultstartActivityForLinkWithProvider(
    @NonNullActivity activity,
    @NonNullFederatedAuthProvider federatedAuthProvider
)

Links the user using the mobile browser (either a Custom Chrome Tab or the device's default browser) to the givenprovider. If the calling activity dies during this operation, usegetPendingAuthResult to get the outcome of this operation.

Note: this call has a UI associated with it, unlike the majority of calls in FirebaseAuth.

Exceptions
Parameters
@NonNullActivity activity

the currentActivity that you intent to launch this flow from

@NonNullFederatedAuthProvider federatedAuthProvider

anFederatedAuthProvider configured with information about the provider that you intend to link to the user.

Returns
@NonNullTask<AuthResult>

aTask with a reference to anAuthResult with user information upon success

startActivityForReauthenticateWithProvider

public @NonNullTask<AuthResultstartActivityForReauthenticateWithProvider(
    @NonNullActivity activity,
    @NonNullFederatedAuthProvider federatedAuthProvider
)

Reauthenticates the user using the mobile browser (either a Custom Chrome Tab or the device's default browser) using the givenprovider. If the calling activity dies during this operation, usegetPendingAuthResult to get the outcome of this operation.

Note: this call has a UI associated with it, unlike the majority of calls in FirebaseAuth.

Exceptions
Parameters
@NonNullActivity activity

the currentActivity that you intent to launch this flow from

@NonNullFederatedAuthProvider federatedAuthProvider

anFederatedAuthProvider configured with information about how you intend the user to reauthenticate.

Returns
@NonNullTask<AuthResult>

aTask with a reference to anAuthResult with user information upon success

unlink

public @NonNullTask<AuthResultunlink(@NonNullString provider)

Detaches credentials from a given provider type from this user. This prevents the user from signing in to this account in the future with credentials from such provider.

Exceptions
Parameters
@NonNullString provider

a unique identifier of the type of provider to be unlinked, for example,PROVIDER_ID.

updateEmail

public @NonNullTask<VoidupdateEmail(@NonNullString email)
This method is deprecated.

UseverifyBeforeUpdateEmail instead.

Updates the email address of the user.

Important: this is a security sensitive operation that requires the user to have recently signed in. If this requirement isn't met, ask the user to authenticate again and later callreauthenticate.

In addition, note that the original email address recipient will receive an email that allows them to revoke the email address change, in order to protect them from account hijacking.

Exceptions

updatePassword

public @NonNullTask<VoidupdatePassword(@NonNullString password)

Updates the password of the user.

Important: this is a security sensitive operation that requires the user to have recently signed in. If this requirement isn't met, ask the user to authenticate again and later callreauthenticate.

Anonymous users who update both their email and password will no longer be anonymous. They will be able to log in with these credentials.

Exceptions

updatePhoneNumber

public @NonNullTask<VoidupdatePhoneNumber(@NonNullPhoneAuthCredential credential)

Updates the phone number of the user.

Important: this is a security sensitive operation that requires the user to have recently signed in. If this requirement isn't met, ask the user to authenticate again and later callreauthenticate.

Exceptions

updateProfile

public @NonNullTask<VoidupdateProfile(@NonNullUserProfileChangeRequest request)

Updates the user profile information. UseUserProfileChangeRequest.Builder to construct the request.

Exceptions

verifyBeforeUpdateEmail

public @NonNullTask<VoidverifyBeforeUpdateEmail(@NonNullString newEmail)

CallsverifyBeforeUpdateEmail without anyactionCodeSettings.

verifyBeforeUpdateEmail

public @NonNullTask<VoidverifyBeforeUpdateEmail(
    @NonNullString newEmail,
    @NullableActionCodeSettings actionCodeSettings
)

Sends a verification email tonewEmail. Upon redemption of the link in the email, this user's email will be changed tonewEmail and that email will be marked verified.

Parameters
@NonNullString newEmail

the user's new email

@NullableActionCodeSettings actionCodeSettings

the optionalActionCodeSettings object to allow linking back to your app in the email

Returns
@NonNullTask<Void>

Task to track completion of the sending operation.

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.