java.lang.Object | |
↳ | com.google.firebase.auth.FirebaseUser |
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 Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Deletes the user record from your Firebase project's database.
| |||||||||||
Returns the main display name of this user from the Firebase project's user database.
| |||||||||||
Returns the main email address of the user, as stored in the Firebase project's user
database.
| |||||||||||
Fetches a Firebase Auth ID Token for the user; useful when authenticating against your own
backend.
| |||||||||||
Returns the phone number of the user, as stored in the Firebase project's user database, or
null if none exists. | |||||||||||
Returns the URL of this user's main profile picture, as stored in the Firebase project's user
database.
| |||||||||||
Always returns
PROVIDER_ID
| |||||||||||
This method is deprecated.
This method is being renamed for functional clarity - please use the
getIdToken(boolean) method instead.
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:
| |||||||||||
Returns a string used to uniquely identify your user in your Firebase project's user
database.
| |||||||||||
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) . | |||||||||||
Attaches the given
AuthCredential to the user. | |||||||||||
Reauthenticates the user with the given credential.
| |||||||||||
Reauthenticates the user with the given credential, and returns the profile data for that
account.
| |||||||||||
Manually refreshes the data of the current user (for example, attached providers, display
name, and so on).
| |||||||||||
Initiates email verification for the user.
| |||||||||||
Detaches credentials from a given provider type from this user.
| |||||||||||
Updates the email address of the user.
| |||||||||||
Updates the password of the user.
| |||||||||||
Updates the phone number of the user.
| |||||||||||
Updates the user profile information.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() |
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)
.
FirebaseAuthInvalidUserException
thrown if the current user's account has been
disabled, deleted, or its credentials are no longer validFirebaseAuthRecentLoginRequiredException
thrown if the user's last sign-in time
does not meet the security threshold. Use reauthenticate(AuthCredential)
to
resolve. This does not apply if the user is anonymous.Returns | |
---|---|
Task<Void> |
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.
Returns | |
---|---|
String |
See also:
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.
Returns | |
---|---|
String |
See also:
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.
FirebaseAuthInvalidUserException
if forceRefresh == true
, thrown if the
current user's account has been disabled, deleted, or its credentials are no longer
validParameters | |
---|---|
forceRefresh |
boolean :
force refreshes the token. Should only be set to true
if the token is invalidated out of band. |
Returns | |
---|---|
Task<GetTokenResult> |
a Task with the GetTokenResult
|
Returns the phone number of the user, as stored in the Firebase project's user database, or
null
if none exists.
This can be updated at any time by calling updatePhoneNumber(PhoneAuthCredential)
.
This field will be automatically populated on account creation if the AuthCredential
used on signInWithCredential(AuthCredential)
contained such information.
This phone number is displayed in the Users section of the Firebase console.
Returns | |
---|---|
String |
See also:
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.
Returns | |
---|---|
Uri |
See also:
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.
Returns | |
---|---|
List<? extends UserInfo> |
This method is deprecated.
This method is being renamed for functional clarity - please use the
getIdToken(boolean)
method instead.
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.
FirebaseAuthInvalidUserException
if forceRefresh == true
, thrown if the
current user's account has been disabled, deleted, or its credentials are no longer
validParameters | |
---|---|
forceRefresh |
boolean :
force refreshes the token. Should only be set to true
if the token is invalidated out of band. |
Returns | |
---|---|
Task<GetTokenResult> |
a Task with the GetTokenResult
|
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.
Returns | |
---|---|
String |
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)
.
Returns | |
---|---|
boolean |
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.
FirebaseAuthWeakPasswordException
thrown if
credential instanceof EmailAuthCredential
and the password is not strong enough
FirebaseAuthInvalidCredentialsException
thrown if the credential
is
malformed or expiredFirebaseAuthUserCollisionException
thrown if there is another user account
associated with the given credential
FirebaseAuthInvalidUserException
thrown if the current user's account has been
disabled, deleted, or its credentials are no longer validFirebaseAuthRecentLoginRequiredException
thrown if
credential instanceof EmailAuthCredential
and if the user's last sign-in time
does not meet the security threshold. Use reauthenticate(AuthCredential)
to
resolve. This does not apply if the user is anonymous.Parameters | |
---|---|
credential |
AuthCredential :
a valid credential of a type not yet linked to this user |
Returns | |
---|---|
Task<AuthResult> |
Task of AuthResult
|
Reauthenticates the user with the given credential. This is useful for operations that
require a recent sign-in, to prevent or resolve a
FirebaseAuthRecentLoginRequiredException
.
FirebaseAuthInvalidUserException
thrown if the current user's account has been
disabled or deletedFirebaseAuthInvalidCredentialsException
thrown if the credential
is
malformed or has expired, or if it corresponds to another existing user's account.
Inspect the error code to desambiguate.Parameters | |
---|---|
credential |
AuthCredential :
authentication credential that must be valid for the current user.
|
Returns | |
---|---|
Task<Void> |
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 a
FirebaseAuthRecentLoginRequiredException
.
FirebaseAuthInvalidUserException
thrown if the current user's account has been
disabled or deleted
FirebaseAuthInvalidCredentialsException
thrown if the credential
is
malformed or has expired, or if it corresponds to another existing user's account.
Inspect the error code to desambiguate.
Parameters | |
---|---|
credential |
AuthCredential :
authentication credential that must be valid for the current user. |
Returns | |
---|---|
Task<AuthResult> |
AuthResult containing the FirebaseUser reference and AdditionalUserInfo .
|
Manually refreshes the data of the current user (for example, attached providers, display name, and so on).
FirebaseAuthInvalidUserException
thrown if the current user's account has been
disabled, deleted, or its credentials are no longer validReturns | |
---|---|
Task<Void> |
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.
FirebaseAuthInvalidUserException
thrown if the current user's account has been
disabled, deleted, or its credentials are no longer validParameters | |
---|---|
provider |
String :
a unique identifier of the type of provider to be unlinked, for example,
PROVIDER_ID . |
Returns | |
---|---|
Task<AuthResult> |
Task of AuthResult
|
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 call reauthenticate(AuthCredential)
.
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.
FirebaseAuthInvalidCredentialsException
thrown if the email
address is
malformedFirebaseAuthUserCollisionException
thrown if there already exists an account
with the given email
addressFirebaseAuthInvalidUserException
thrown if the current user's account has been
disabled, deleted, or its credentials are no longer validFirebaseAuthRecentLoginRequiredException
thrown if the user's last sign-in time
does not meet the security threshold. Use reauthenticate(AuthCredential)
to
resolve. This does not apply if the user is anonymous.Parameters | |
---|---|
email |
String
|
Returns | |
---|---|
Task<Void> |
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 call reauthenticate(AuthCredential)
.
FirebaseAuthWeakPasswordException
thrown if the password is not strong enough
FirebaseAuthInvalidUserException
thrown if the current user's account has been
disabled, deleted, or its credentials are no longer validFirebaseAuthRecentLoginRequiredException
thrown if the user's last sign-in time
does not meet the security threshold. Use reauthenticate(AuthCredential)
to
resolve. This does not apply if the user is anonymous.Parameters | |
---|---|
password |
String
|
Returns | |
---|---|
Task<Void> |
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 call reauthenticate(AuthCredential)
.
FirebaseAuthUserCollisionException
thrown if there already exists an account
with the given phone numberFirebaseAuthInvalidUserException
thrown if the current user's account has been
disabled, deleted, or its credentials are no longer validFirebaseAuthRecentLoginRequiredException
thrown if the user's last sign-in time
does not meet the security threshold. Use reauthenticate(AuthCredential)
to
resolve. This does not apply if the user is anonymous.Parameters | |
---|---|
credential |
PhoneAuthCredential
|
Returns | |
---|---|
Task<Void> |
Updates the user profile information. Use UserProfileChangeRequest.Builder
to
construct the request.
FirebaseAuthInvalidUserException
thrown if the current user's account has been
disabled, deleted, or its credentials are no longer validParameters | |
---|---|
request |
UserProfileChangeRequest
|
Returns | |
---|---|
Task<Void> |