User interface Stay organized with collections Save and categorize content based on your preferences.
A user account.
Signature:
exportinterfaceUserextendsUserInfoExtends:UserInfo
Properties
| Property | Type | Description |
|---|---|---|
| emailVerified | boolean | Whether the email has been verified withsendEmailVerification() andapplyActionCode(). |
| isAnonymous | boolean | Whether the user is authenticated using theProviderId.ANONYMOUS provider. |
| metadata | UserMetadata | Additional metadata around user creation and sign-in times. |
| providerData | UserInfo[] | Additional per provider such as displayName and profile information. |
| refreshToken | string | Refresh token used to reauthenticate the user. Avoid using this directly and preferUser.getIdToken() to refresh the ID token instead. |
| tenantId | string | null | The user's tenant ID. |
Methods
| Method | Description |
|---|---|
| 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
| Parameter | Type | Description |
|---|---|---|
| forceRefresh | boolean | Force 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
| Parameter | Type | Description |
|---|---|---|
| forceRefresh | boolean | Force 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.