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

OAuthProvider.credential() method

Creates a OAuthCredential from a generic OAuth provider's access token or ID token.

Signature:

credential(params: OAuthCredentialOptions): OAuthCredential;

Parameters

Parameter Type Description
params OAuthCredentialOptions Either the options object containing the ID token, access token and raw nonce or the ID token string.

Returns:

OAuthCredential

Description

The raw nonce is required when an ID token with a nonce field is provided. The SHA-256 hash of the raw nonce must match the nonce field in the ID token.

Example

// `googleUser` from the onsuccess Google Sign In callback.
// Initialize a generate OAuth provider with a `google.com` providerId.
const provider = new OAuthProvider('google.com');
const credential = provider.credential({
  idToken: googleUser.getAuthResponse().id_token,
});
const result = await signInWithCredential(credential);