The Firebase JS SDK is now in BETA!
This EAP site is no longer maintained. See the official Firebase Documentation site for the latest documentation and information about the Firebase JS SDK.

Home > @firebase/auth > getIdToken

getIdToken() function

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

Signature:

export declare function getIdToken(user: User, forceRefresh?: boolean): Promise<string>;

Parameters

Parameter Type Description
user User The user.
forceRefresh boolean Force refresh regardless of token expiration.

Returns:

Promise<string>

Description

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.