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 > GoogleAuthProvider > credential

GoogleAuthProvider.credential() method

Creates a credential for Google. At least one of ID token and access token is required.

Signature:

static credential(idToken?: string | null, accessToken?: string | null): OAuthCredential;

Parameters

Parameter Type Description
idToken string | null Google ID token.
accessToken string | null Google access token.

Returns:

OAuthCredential

Example

// \`googleUser\` from the onsuccess Google Sign In callback.
const credential = GoogleAuthProvider.credential(googleUser.getAuthResponse().id_token);
const result = await signInWithCredential(credential);