<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@firebase/auth](./auth.md) &gt; [OAuthProvider](./auth.oauthprovider.md)

## OAuthProvider class

Provider for generating generic [OAuthCredential](./auth.oauthcredential.md)<!-- -->.

<b>Signature:</b>

```typescript
export declare class OAuthProvider implements AuthProvider 
```
<b>Implements:</b> [AuthProvider](./auth.authprovider.md)

## Example 1


```javascript
// Sign in using a redirect.
const provider = new OAuthProvider('google.com');
// Start a sign in process for an unauthenticated user.
provider.addScope('profile');
provider.addScope('email');
await signInWithRedirect(auth, provider);
// This will trigger a full page redirect away from your app

// After returning from the redirect when your app initializes you can obtain the result
const result = await getRedirectResult(auth);
if (result) {
  // This is the signed-in user
  const user = result.user;
  // This gives you a OAuth Access Token for the provider.
  const credential = provider.credentialFromResult(auth, result);
  const token = credential.accessToken;
}

```

## Example 2


```javascript
// Sign in using a popup.
const provider = new OAuthProvider('google.com');
provider.addScope('profile');
provider.addScope('email');
const result = await signInWithPopup(auth, provider);

// The signed-in user info.
const user = result.user;
// This gives you a OAuth Access Token for the provider.
const credential = provider.credentialFromResult(auth, result);
const token = credential.accessToken;

```

## Constructors

|  Constructor | Modifiers | Description |
|  --- | --- | --- |
|  [(constructor)(providerId)](./auth.oauthprovider._constructor_.md) |  | Constructor for generic OAuth providers. |

## Properties

|  Property | Modifiers | Type | Description |
|  --- | --- | --- | --- |
|  [providerId](./auth.oauthprovider.providerid.md) |  | string |  |

## Methods

|  Method | Modifiers | Description |
|  --- | --- | --- |
|  [addScope(scope)](./auth.oauthprovider.addscope.md) |  | Add an OAuth scope to the credential. |
|  [credential(params)](./auth.oauthprovider.credential.md) |  | Creates a [OAuthCredential](./auth.oauthcredential.md) from a generic OAuth provider's access token or ID token. |
|  [credentialFromError(error)](./auth.oauthprovider.credentialfromerror.md) | <code>static</code> | Used to extract the underlying [OAuthCredential](./auth.oauthcredential.md) from a [AuthError](./auth.autherror.md) which was thrown during a sign-in, link, or reauthenticate operation. |
|  [credentialFromJSON(json)](./auth.oauthprovider.credentialfromjson.md) | <code>static</code> |  |
|  [credentialFromResult(userCredential)](./auth.oauthprovider.credentialfromresult.md) | <code>static</code> | Used to extract the underlying [OAuthCredential](./auth.oauthcredential.md) from a [UserCredential](./auth.usercredential.md)<!-- -->. |
|  [getCustomParameters()](./auth.oauthprovider.getcustomparameters.md) |  | Retrieve the current list of [CustomParameters](./auth.customparameters.md)<!-- -->. |
|  [getScopes()](./auth.oauthprovider.getscopes.md) |  | Retrieve the current list of OAuth scopes. |
|  [setCustomParameters(customOAuthParameters)](./auth.oauthprovider.setcustomparameters.md) |  | Sets the OAuth custom parameters to pass in an OAuth request for popup and redirect sign-in operations. |
|  [setDefaultLanguage(languageCode)](./auth.oauthprovider.setdefaultlanguage.md) |  | Set the language gode. |

