Properties

displayName

unknown

The user's display name (if available).

Inherited from
firebase.UserInfo#displayName

email

unknown

The user's email address (if available).

Inherited from
firebase.UserInfo#email

emailVerified

boolean

True if the user's email address has been verified.

isAnonymous

boolean

photoURL

unknown

The URL of the user's profile picture (if available).

Inherited from
firebase.UserInfo#photoURL

providerData

non-null Array of firebase.UserInfo

Additional provider-specific information about the user.

providerId

unknown

The authentication provider ID for the current user. For example, 'facebook.com', or 'google.com'.

Inherited from
firebase.UserInfo#providerId

refreshToken

string

A refresh token for the user account. Use only for advanced scenarios that require explicitly refreshing tokens.

uid

unknown

The user's unique ID.

Inherited from
firebase.UserInfo#uid

Methods

delete

delete() returns firebase.Promise containing void

Deletes and signs out 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 then call firebase.User#reauthenticate.

Error Codes

auth/requires-recent-login
Thrown if the user's last sign-in time does not meet the security threshold. Use firebase.User#reauthenticate to resolve. This does not apply if the user is anonymous.
Returns

non-null firebase.Promise containing void 

getToken

getToken(forceRefresh) returns firebase.Promise containing string

Returns a JWT token used to identify the user to a Firebase service.

Returns the current token if it has not expired, otherwise this will refresh the token and return a new one.

Parameter

forceRefresh

Optional

boolean

Force refresh regardless of token expiration.

Returns

non-null firebase.Promise containing string 

link(credential) returns firebase.Promise containing non-null firebase.User

Links the user account with the given credentials.

This API is deprecated. Use firebase.User#linkWithCredential instead.

Error Codes

auth/provider-already-linked
Thrown if the provider has already been linked to the user. This error is thrown even if this is not the same provider's account that is currently linked to the user.
auth/invalid-credential
Thrown if the provider's credential is not valid. This can happen if it has already expired when calling link, or if it used invalid token(s). See the Firebase documentation for your provider, and make sure you pass in the correct parameters to the credential method.
auth/credential-already-in-use
Thrown if the account corresponding to the credential already exists among your users, or is already linked to a Firebase User. For example, this error could be thrown if you are upgrading an anonymous user to a Google user by linking a Google credential to it and the Google credential used is already associated with an existing Firebase Google user. An error.email and error.credential ( firebase.auth.AuthCredential) fields are also provided. You can recover from this error by signing in with that credential directly via firebase.auth.Auth#signInWithCredential.
auth/email-already-in-use
Thrown if the email corresponding to the credential already exists among your users. When thrown while linking a credential to an existing user, an error.email and error.credential ( firebase.auth.AuthCredential) fields are also provided. You have to link the credential to the existing user with that email if you wish to continue signing in with that credential. To do so, call firebase.auth.Auth#fetchProvidersForEmail, sign in to error.email via one of the providers returned and then firebase.User#link the original credential to that newly signed in user.
auth/operation-not-allowed
Thrown if you have not enabled the provider in the Firebase Console. Go to the Firebase Console for your project, in the Auth section and the Sign in Method tab and configure the provider.
auth/invalid-email
Thrown if the email used in a firebase.auth.EmailAuthProvider#credential is invalid.
auth/wrong-password
Thrown if the password used in a firebase.auth.EmailAuthProvider#credential is not correct or when the user associated with the email does not have a password.

Parameter

credential

firebase.auth.AuthCredential

The auth credential.

Value must not be null.

Returns

non-null firebase.Promise containing non-null firebase.User 

Deprecated

linkWithCredential

linkWithCredential(credential) returns firebase.Promise containing non-null firebase.User

Links the user account with the given credentials.

Error Codes

auth/provider-already-linked
Thrown if the provider has already been linked to the user. This error is thrown even if this is not the same provider's account that is currently linked to the user.
auth/invalid-credential
Thrown if the provider's credential is not valid. This can happen if it has already expired when calling link, or if it used invalid token(s). See the Firebase documentation for your provider, and make sure you pass in the correct parameters to the credential method.
auth/credential-already-in-use
Thrown if the account corresponding to the credential already exists among your users, or is already linked to a Firebase User. For example, this error could be thrown if you are upgrading an anonymous user to a Google user by linking a Google credential to it and the Google credential used is already associated with an existing Firebase Google user. An error.email and error.credential ( firebase.auth.AuthCredential) fields are also provided. You can recover from this error by signing in with that credential directly via firebase.auth.Auth#signInWithCredential.
auth/email-already-in-use
Thrown if the email corresponding to the credential already exists among your users. When thrown while linking a credential to an existing user, an error.email and error.credential ( firebase.auth.AuthCredential) fields are also provided. You have to link the credential to the existing user with that email if you wish to continue signing in with that credential. To do so, call firebase.auth.Auth#fetchProvidersForEmail, sign in to error.email via one of the providers returned and then firebase.User#link the original credential to that newly signed in user.
auth/operation-not-allowed
Thrown if you have not enabled the provider in the Firebase Console. Go to the Firebase Console for your project, in the Auth section and the Sign in Method tab and configure the provider.
auth/invalid-email
Thrown if the email used in a firebase.auth.EmailAuthProvider#.credential is invalid.
auth/wrong-password
Thrown if the password used in a firebase.auth.EmailAuthProvider#.credential is not correct or when the user associated with the email does not have a password.

Parameter

credential

firebase.auth.AuthCredential

The auth credential.

Value must not be null.

Returns

non-null firebase.Promise containing non-null firebase.User 

linkWithPopup

linkWithPopup(provider) returns firebase.Promise containing non-null firebase.auth.UserCredential

Links the authenticated provider to the user account using a pop-up based OAuth flow.

If the linking is successful, the returned result will contain the user and the provider's credential.

Error Codes

auth/auth-domain-config-required
Thrown if authDomain configuration is not provided when calling firebase.initializeApp(). Check Firebase Console for instructions on determining and passing that field.
auth/cancelled-popup-request
Thrown if successive popup operations are triggered. Only one popup request is allowed at one time on a user or an auth instance. All the popups would fail with this error except for the last one.
auth/credential-already-in-use
Thrown if the account corresponding to the credential already exists among your users, or is already linked to a Firebase User. For example, this error could be thrown if you are upgrading an anonymous user to a Google user by linking a Google credential to it and the Google credential used is already associated with an existing Firebase Google user. An error.email and error.credential ( firebase.auth.AuthCredential) fields are also provided. You can recover from this error by signing in with that credential directly via firebase.auth.Auth#signInWithCredential.
auth/email-already-in-use
Thrown if the email corresponding to the credential already exists among your users. When thrown while linking a credential to an existing user, an error.email and error.credential ( firebase.auth.AuthCredential) fields are also provided. You have to link the credential to the existing user with that email if you wish to continue signing in with that credential. To do so, call firebase.auth.Auth#fetchProvidersForEmail, sign in to error.email via one of the providers returned and then firebase.User#link the original credential to that newly signed in user.
auth/operation-not-allowed
Thrown if you have not enabled the provider in the Firebase Console. Go to the Firebase Console for your project, in the Auth section and the Sign in Method tab and configure the provider.
auth/popup-blocked
auth/operation-not-supported-in-this-environment
Thrown if this operation is not supported in the environment your application is running on. "location.protocol" must be http or https.
Thrown if the popup was blocked by the browser, typically when this operation is triggered outside of a click handler.
auth/popup-closed-by-user
Thrown if the popup window is closed by the user without completing the sign in to the provider.
auth/provider-already-linked
Thrown if the provider has already been linked to the user. This error is thrown even if this is not the same provider's account that is currently linked to the user.
auth/unauthorized-domain
Thrown if the app domain is not authorized for OAuth operations for your Firebase project. Edit the list of authorized domains from the Firebase console.

Parameter

provider

firebase.auth.AuthProvider

The provider to authenticate. The provider has to be an OAuth provider. Non-OAuth providers like firebase.auth.EmailAuthProvider will throw an error.

Value must not be null.

Returns

non-null firebase.Promise containing non-null firebase.auth.UserCredential 

Example

// Creates the provider object.
var provider = new firebase.auth.FacebookAuthProvider();
// You can add additional scopes to the provider:
provider.addScope('email');
provider.addScope('user_friends');
// Link with popup:
user.linkWithPopup(provider).then(function(result) {
  // The firebase.User instance:
  var user = result.user;
  // The Facebook firebase.auth.AuthCredential containing the Facebook
  // access token:
  var credential = result.credential;
}, function(error) {
  // An error happened.
});

linkWithRedirect

linkWithRedirect(provider) returns firebase.Promise containing void

Links the authenticated provider to the user account using a full-page redirect flow.

Error Codes

auth/auth-domain-config-required
Thrown if authDomain configuration is not provided when calling firebase.initializeApp(). Check Firebase Console for instructions on determining and passing that field.
auth/operation-not-supported-in-this-environment
Thrown if this operation is not supported in the environment your application is running on. "location.protocol" must be http or https.
auth/provider-already-linked
Thrown if the provider has already been linked to the user. This error is thrown even if this is not the same provider's account that is currently linked to the user.
auth/unauthorized-domain
Thrown if the app domain is not authorized for OAuth operations for your Firebase project. Edit the list of authorized domains from the Firebase console.

Parameter

provider

firebase.auth.AuthProvider

The provider to authenticate. The provider has to be an OAuth provider. Non-OAuth providers like firebase.auth.EmailAuthProvider will throw an error.

Value must not be null.

Returns

non-null firebase.Promise containing void 

reauthenticate

reauthenticate(credential) returns firebase.Promise containing void

Re-authenticates a user using a fresh credential. Use before operations such as firebase.User#updatePassword that require tokens from recent sign-in attempts.

This API is deprecated. Use firebase.User#reauthenticateWithCredential instead.

Error Codes

auth/user-mismatch
Thrown if the credential given does not correspond to the user.
auth/user-not-found
Thrown if the credential given does not correspond to any existing user.
auth/invalid-credential
Thrown if the provider's credential is not valid. This can happen if it has already expired when calling link, or if it used invalid token(s). See the Firebase documentation for your provider, and make sure you pass in the correct parameters to the credential method.
auth/invalid-email
Thrown if the email used in a firebase.auth.EmailAuthProvider#credential is invalid.
auth/wrong-password
Thrown if the password used in a firebase.auth.EmailAuthProvider#credential is not correct or when the user associated with the email does not have a password.

Parameter

credential

firebase.auth.AuthCredential

Value must not be null.

Returns

non-null firebase.Promise containing void 

Deprecated

reauthenticateWithCredential

reauthenticateWithCredential(credential) returns firebase.Promise containing void

Re-authenticates a user using a fresh credential. Use before operations such as firebase.User#updatePassword that require tokens from recent sign-in attempts.

Error Codes

auth/user-mismatch
Thrown if the credential given does not correspond to the user.
auth/user-not-found
Thrown if the credential given does not correspond to any existing user.
auth/invalid-credential
Thrown if the provider's credential is not valid. This can happen if it has already expired when calling link, or if it used invalid token(s). See the Firebase documentation for your provider, and make sure you pass in the correct parameters to the credential method.
auth/invalid-email
Thrown if the email used in a firebase.auth.EmailAuthProvider#credential is invalid.
auth/wrong-password
Thrown if the password used in a firebase.auth.EmailAuthProvider#credential is not correct or when the user associated with the email does not have a password.

Parameter

credential

firebase.auth.AuthCredential

Value must not be null.

Returns

non-null firebase.Promise containing void 

reauthenticateWithPopup

reauthenticateWithPopup(provider) returns firebase.Promise containing non-null firebase.auth.UserCredential

Reauthenticates the current user with the specified provider using a pop-up based OAuth flow.

If the reauthentication is successful, the returned result will contain the user and the provider's credential.

Error Codes

auth/auth-domain-config-required
Thrown if authDomain configuration is not provided when calling firebase.initializeApp(). Check Firebase Console for instructions on determining and passing that field.
auth/cancelled-popup-request
Thrown if successive popup operations are triggered. Only one popup request is allowed at one time on a user or an auth instance. All the popups would fail with this error except for the last one.
auth/user-mismatch
Thrown if the credential given does not correspond to the user.
auth/operation-not-allowed
Thrown if you have not enabled the provider in the Firebase Console. Go to the Firebase Console for your project, in the Auth section and the Sign in Method tab and configure the provider.
auth/popup-blocked
Thrown if the popup was blocked by the browser, typically when this operation is triggered outside of a click handler.
auth/operation-not-supported-in-this-environment
Thrown if this operation is not supported in the environment your application is running on. "location.protocol" must be http or https.
auth/popup-closed-by-user
Thrown if the popup window is closed by the user without completing the sign in to the provider.
auth/unauthorized-domain
Thrown if the app domain is not authorized for OAuth operations for your Firebase project. Edit the list of authorized domains from the Firebase console.

Parameter

provider

firebase.auth.AuthProvider

The provider to authenticate. The provider has to be an OAuth provider. Non-OAuth providers like firebase.auth.EmailAuthProvider will throw an error.

Value must not be null.

Returns

non-null firebase.Promise containing non-null firebase.auth.UserCredential 

Example

// Creates the provider object.
var provider = new firebase.auth.FacebookAuthProvider();
// You can add additional scopes to the provider:
provider.addScope('email');
provider.addScope('user_friends');
// Reauthenticate with popup:
user.reauthenticateWithPopup(provider).then(function(result) {
  // The firebase.User instance:
  var user = result.user;
  // The Facebook firebase.auth.AuthCredential containing the Facebook
  // access token:
  var credential = result.credential;
}, function(error) {
  // An error happened.
});

reauthenticateWithRedirect

reauthenticateWithRedirect(provider) returns firebase.Promise containing void

Reauthenticates the current user with the specified OAuth provider using a full-page redirect flow.

Error Codes

auth/auth-domain-config-required
Thrown if authDomain configuration is not provided when calling firebase.initializeApp(). Check Firebase Console for instructions on determining and passing that field.
auth/operation-not-supported-in-this-environment
Thrown if this operation is not supported in the environment your application is running on. "location.protocol" must be http or https.
auth/user-mismatch
Thrown if the credential given does not correspond to the user.
auth/unauthorized-domain
Thrown if the app domain is not authorized for OAuth operations for your Firebase project. Edit the list of authorized domains from the Firebase console.

Parameter

provider

firebase.auth.AuthProvider

The provider to authenticate. The provider has to be an OAuth provider. Non-OAuth providers like firebase.auth.EmailAuthProvider will throw an error.

Value must not be null.

Returns

non-null firebase.Promise containing void 

reload

reload() returns firebase.Promise containing void

Refreshes the current user, if signed in.

Returns

non-null firebase.Promise containing void 

sendEmailVerification

sendEmailVerification() returns firebase.Promise containing void

Sends a verification email to a user.

The verification process is completed by calling firebase.auth.Auth#applyActionCode

Returns

non-null firebase.Promise containing void 

toJSON

toJSON() returns Object

Returns a JSON-serializable representation of this object.

Returns

non-null Object A JSON-serializable representation of this object.

unlink(providerId) returns firebase.Promise containing non-null firebase.User

Unlinks a provider from a user account.

Error Codes

auth/no-such-provider
Thrown if the user does not have this provider linked or when the provider ID given does not exist.

Parameter

providerId

string

Returns

non-null firebase.Promise containing non-null firebase.User 

updateEmail

updateEmail(newEmail) returns firebase.Promise containing void

Updates the user's email address.

An email will be sent to the original email address (if it was set) that allows to revoke the email address change, in order to protect them from account hijacking.

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 then call firebase.User#reauthenticate.

Error Codes

auth/invalid-email
Thrown if the email used is invalid.
auth/email-already-in-use
Thrown if the email is already used by another user.
auth/requires-recent-login
Thrown if the user's last sign-in time does not meet the security threshold. Use firebase.User#reauthenticate to resolve. This does not apply if the user is anonymous.

Parameter

newEmail

string

The new email address.

Returns

non-null firebase.Promise containing void 

updatePassword

updatePassword(newPassword) returns firebase.Promise containing void

Updates the user's password.

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 then call firebase.User#reauthenticate.

Error Codes

auth/weak-password
Thrown if the password is not strong enough.
auth/requires-recent-login
Thrown if the user's last sign-in time does not meet the security threshold. Use firebase.User#reauthenticate to resolve. This does not apply if the user is anonymous.

Parameter

newPassword

string

Returns

non-null firebase.Promise containing void 

updateProfile

updateProfile(profile) returns firebase.Promise containing void

Updates a user's profile data.

Parameter

profile

{displayName: nullable string, photoURL: nullable string}

The profile's displayName and photoURL to update.

Value must not be null.

Returns

non-null firebase.Promise containing void 

Example

// Updates the user attributes:
user.updateProfile({
  displayName: "Jane Q. User",
  photoURL: "https://example.com/jane-q-user/profile.jpg"
}).then(function() {
  // Profile updated successfully!
  // "Jane Q. User"
  var displayName = user.displayName;
  // "https://example.com/jane-q-user/profile.jpg"
  var photoURL = user.photoURL;
}, function(error) {
  // An error happened.
});

// Passing a null value will delete the current attribute's value, but not
// passing a property won't change the current attribute's value:
// Let's say we're using the same user than before, after the update.
user.updateProfile({photoURL: null}).then(function() {
  // Profile updated successfully!
  // "Jane Q. User", hasn't changed.
  var displayName = user.displayName;
  // Now, this is null.
  var photoURL = user.photoURL;
}, function(error) {
  // An error happened.
});