User interface

A user account.

Signature:

exportinterfaceUserextendsUserInfo

Extends:UserInfo

Properties

PropertyTypeDescription
emailVerifiedbooleanWhether the email has been verified withsendEmailVerification() andapplyActionCode().
isAnonymousbooleanWhether the user is authenticated using theProviderId.ANONYMOUS provider.
metadataUserMetadataAdditional metadata around user creation and sign-in times.
providerDataUserInfo[]Additional per provider such as displayName and profile information.
refreshTokenstringRefresh token used to reauthenticate the user. Avoid using this directly and preferUser.getIdToken() to refresh the ID token instead.
tenantIdstring | nullThe user's tenant ID.

Methods

MethodDescription
delete()Deletes and signs out the user.
getIdToken(forceRefresh)Returns a JSON Web Token (JWT) used to identify the user to a Firebase service.
getIdTokenResult(forceRefresh)Returns a deserialized JSON Web Token (JWT) used to identify the user to a Firebase service.
reload()Refreshes the user, if signed in.
toJSON()Returns a JSON-serializable representation of this object.

User.emailVerified

Whether the email has been verified withsendEmailVerification() andapplyActionCode().

Signature:

readonlyemailVerified:boolean;

User.isAnonymous

Whether the user is authenticated using theProviderId.ANONYMOUS provider.

Signature:

readonlyisAnonymous:boolean;

User.metadata

Additional metadata around user creation and sign-in times.

Signature:

readonlymetadata:UserMetadata;

User.providerData

Additional per provider such as displayName and profile information.

Signature:

readonlyproviderData:UserInfo[];

User.refreshToken

Refresh token used to reauthenticate the user. Avoid using this directly and preferUser.getIdToken() to refresh the ID token instead.

Signature:

readonlyrefreshToken:string;

User.tenantId

The user's tenant ID.

This is a read-only property, which indicates the tenant ID used to sign in the user. This is null if the user is signed in from the parent project.

Signature:

readonlytenantId:string|null;

Example

// Set the tenant ID on Auth instance.auth.tenantId='TENANT_PROJECT_ID';// All future sign-in request now include tenant ID.constresult=awaitsignInWithEmailAndPassword(auth,email,password);// result.user.tenantId should be 'TENANT_PROJECT_ID'.

User.delete()

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 one of the reauthentication methods likereauthenticateWithCredential().

This method is not supported on anyUser signed in byAuth instances created with aFirebaseServerApp.

Signature:

delete():Promise<void>;

Returns:

Promise<void>

User.getIdToken()

Returns a JSON Web Token (JWT) used to identify the user to a Firebase service.

Returns the current token if it has not expired or if it will not expire in the next five minutes. Otherwise, this will refresh the token and return a new one.

Signature:

getIdToken(forceRefresh?:boolean):Promise<string>;

Parameters

ParameterTypeDescription
forceRefreshbooleanForce refresh regardless of token expiration.

Returns:

Promise<string>

User.getIdTokenResult()

Returns a deserialized JSON Web Token (JWT) used to identify the user to a Firebase service.

Returns the current token if it has not expired or if it will not expire in the next five minutes. Otherwise, this will refresh the token and return a new one.

Signature:

getIdTokenResult(forceRefresh?:boolean):Promise<IdTokenResult>;

Parameters

ParameterTypeDescription
forceRefreshbooleanForce refresh regardless of token expiration.

Returns:

Promise<IdTokenResult>

User.reload()

Refreshes the user, if signed in.

Signature:

reload():Promise<void>;

Returns:

Promise<void>

User.toJSON()

Returns a JSON-serializable representation of this object.

Signature:

toJSON():object;

Returns:

object

A JSON-serializable representation of this object.

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 2024-03-28 UTC.