FirebaseUser

public abstract class FirebaseUser extends Object
implements 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.

Public Constructor Summary

Public Method Summary

Task<Void>
delete()
Deletes the user record from your Firebase project's database.
abstract String
getDisplayName()
Returns the main display name of this user from the Firebase project's user database.
abstract String
getEmail()
Returns the main email address of the user, as stored in the Firebase project's user database.
abstract Uri
getPhotoUrl()
Returns the URL of this user's main profile picture, as stored in the Firebase project's user database.
abstract List<? extends UserInfo>
getProviderData()
Returns a List of UserInfo objects that represents the linked identities of the user using different authentication providers that may be linked to their account.
abstract String
getProviderId()
Always returns PROVIDER_ID
Task<GetTokenResult>
getToken(boolean forceRefresh)
Fetches a Firebase Auth ID Token for the user; useful when authenticating against your own backend.
abstract String
getUid()
Returns a string used to uniquely identify your user in your Firebase project's user database.
abstract boolean
isAnonymous()
Returns true if the user is anonymous; that is, the user account was created with signInAnonymously() and has not been linked to another account with linkWithCredential(AuthCredential).
Task<AuthResult>
linkWithCredential(AuthCredential credential)
Attaches the given AuthCredential to the user.
Task<Void>
reauthenticate(AuthCredential credential)
Reauthenticates the user with the given credential.
Task<Void>
reload()
Manually refreshes the data of the current user (for example, attached providers, display name, and so on).
Task<Void>
sendEmailVerification()
Initiates email verification for the user.
Task<AuthResult>
unlink(String provider)
Detaches credentials from a given provider type from this user.
Task<Void>
updateEmail(String email)
Updates the email address of the user.
Task<Void>
updatePassword(String password)
Updates the password of the user.
Task<Void>
updateProfile(UserProfileChangeRequest request)
Updates the user profile information.

Inherited Method Summary

Public Constructors

public FirebaseUser ()

Public Methods

public Task<Void> delete ()

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 call reauthenticate(AuthCredential).

Exceptions:

public abstract String getDisplayName ()

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

This field will be automatically populated on account creation if the AuthCredential used on signInWithCredential(AuthCredential) contained such information.

public abstract String getEmail ()

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

This field will be automatically populated on account creation if the AuthCredential used on signInWithCredential(AuthCredential) contained such information, or if the account was created with createUserWithEmailAndPassword(String, String).

If the user also has a password, this email address can be used to sign in into the account using signInWithEmailAndPassword(String, String).

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

public abstract Uri 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 of UserInfo corresponding to authentication providers (like Facebook Login), which is not modifiable, this URL can be updated at any time by calling updateProfile(UserProfileChangeRequest).

This field will be automatically populated on account creation if the AuthCredential used on signInWithCredential(AuthCredential) contained such information.

public abstract List<? extends UserInfo> getProviderData ()

Returns a List of UserInfo 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.

public abstract String getProviderId ()

Always returns PROVIDER_ID

public Task<GetTokenResult> getToken (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 if forceRefresh == true, thrown if the current user's account has been disabled, deleted, or its credentials are no longer valid

Parameters
forceRefresh force refreshes the token. Should only be set to true if the token is invalidated out of band.
Returns

public abstract String 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.

public abstract boolean isAnonymous ()

Returns true if the user is anonymous; that is, the user account was created with signInAnonymously() and has not been linked to another account with linkWithCredential(AuthCredential).

public Task<AuthResult> linkWithCredential (AuthCredential credential)

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