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:
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);