Naar console

A user account.

Index

Properties

displayName

displayName: string | null

email

email: string | null

emailVerified

emailVerified: boolean

isAnonymous

isAnonymous: boolean

metadata

metadata: UserMetadata

phoneNumber

phoneNumber: string | null

The phone number normalized based on the E.164 standard (e.g. +16505550101) for the current user. This is null if the user has no phone credential linked to the account.

photoURL

photoURL: string | null

providerData

providerData: UserInfo[]

providerId

providerId: string

refreshToken

refreshToken: string

uid

uid: string

The user's unique ID.

Methods

delete

  • delete(): Promise<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.reauthenticateWithCredential.

    Error Codes

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

    Returns Promise<void>

getIdToken

  • getIdToken(forceRefresh?: boolean): Promise<string>
  • Returns a JSON Web Token (JWT) 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.

    Parameters

    • Optional forceRefresh: boolean

      Force refresh regardless of token expiration.

    Returns Promise<string>

getIdTokenResult

  • getIdTokenResult(forceRefresh?: boolean): Promise<IdTokenResult>
  • Parameters

    • Optional forceRefresh: boolean

    Returns Promise<IdTokenResult>

linkAndRetrieveDataWithCredential

  • linkAndRetrieveDataWithCredential(credential: AuthCredential): Promise<UserCredential>
  • deprecated

    Links the user account with the given credentials and returns any available additional user information, such as user name.

    This method 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. The fields error.email, error.phoneNumber, and error.credential (firebase.auth.AuthCredential) may be provided, depending on the type of credential. You can recover from this error by signing in with error.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.fetchSignInMethodsForEmail, sign in to error.email via one of the providers returned and then firebase.User.linkWithCredential 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.
    auth/invalid-verification-code
    Thrown if the credential is a firebase.auth.PhoneAuthProvider.credential and the verification code of the credential is not valid.
    auth/invalid-verification-id
    Thrown if the credential is a firebase.auth.PhoneAuthProvider.credential and the verification ID of the credential is not valid.

    Parameters

    Returns Promise<UserCredential>

linkWithCredential

  • linkWithCredential(credential: AuthCredential): Promise<UserCredential>
  • 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. The fields error.email, error.phoneNumber, and error.credential (firebase.auth.AuthCredential) may be provided, depending on the type of credential. You can recover from this error by signing in with error.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.fetchSignInMethodsForEmail, sign in to error.email via one of the providers returned and then firebase.User.linkWithCredential 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.
    auth/invalid-verification-code
    Thrown if the credential is a firebase.auth.PhoneAuthProvider.credential and the verification code of the credential is not valid.
    auth/invalid-verification-id
    Thrown if the credential is a firebase.auth.PhoneAuthProvider.credential and the verification ID of the credential is not valid.

    Parameters

    Returns Promise<UserCredential>

linkWithPhoneNumber

  • linkWithPhoneNumber(phoneNumber: string, applicationVerifier: ApplicationVerifier): Promise<ConfirmationResult>
  • Links the user account with the given phone number.

    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/captcha-check-failed
    Thrown if the reCAPTCHA response token was invalid, expired, or if this method was called from a non-whitelisted domain.
    auth/invalid-phone-number
    Thrown if the phone number has an invalid format.
    auth/missing-phone-number
    Thrown if the phone number is missing.
    auth/quota-exceeded
    Thrown if the SMS quota for the Firebase project has been exceeded.
    auth/user-disabled
    Thrown if the user corresponding to the given phone number has been disabled.
    auth/credential-already-in-use
    Thrown if the account corresponding to the phone number already exists among your users, or is already linked to a Firebase User. The fields error.phoneNumber and error.credential (firebase.auth.AuthCredential) are provided in this case. You can recover from this error by signing in with that credential directly via firebase.auth.Auth.signInWithCredential.
    auth/operation-not-allowed
    Thrown if you have not enabled the phone authentication 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.

    Parameters

    • phoneNumber: