---
title: supertokens-node/recipe/oauth2provider
description: References documentation for the supertokens-node/recipe/oauth2provider package
sidebar:
  order: 230
---

## Classes

### default

Defined in: [recipe/oauth2provider/index.ts:28](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/oauth2provider/index.ts#L28)

#### Constructors

##### Constructor

```ts check=false reason="Generated API signature"
new default(): default;
```

###### Returns

[`default`](#default)

#### Properties

| Property | Modifier | Type | Default value | Defined in |
| ------ | ------ | ------ | ------ | ------ |
| <a id="member-default-init"></a> `init` | `static` | (`config?`) => [`RecipeListFunction`](types#recipelistfunction) | `Recipe.init` | [recipe/oauth2provider/index.ts:29](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/oauth2provider/index.ts#L29) |

#### Methods

##### createOAuth2Client()

```ts check=false reason="Generated API signature"
static createOAuth2Client(input, userContext?): Promise<
  | {
  client: OAuth2Client;
  status: "OK";
}
  | {
  error: string;
  errorDescription: string;
  status: "ERROR";
}>;
```

Defined in: [recipe/oauth2provider/index.ts:43](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/oauth2provider/index.ts#L43)

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `input` | [`CreateOAuth2ClientInput`](recipe-oauth2provider-types#createoauth2clientinput) |
| `userContext?` | `Record`\<`string`, `any`\> |

###### Returns

`Promise`\<
  \| \{
  `client`: `OAuth2Client`;
  `status`: `"OK"`;
\}
  \| \{
  `error`: `string`;
  `errorDescription`: `string`;
  `status`: `"ERROR"`;
\}\>

##### createTokenForClientCredentials()

```ts check=false reason="Generated API signature"
static createTokenForClientCredentials(
   clientId, 
   clientSecret, 
   scope?, 
   audience?, 
   userContext?): Promise<
  | ErrorOAuth2
| TokenInfo>;
```

Defined in: [recipe/oauth2provider/index.ts:80](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/oauth2provider/index.ts#L80)

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `clientId` | `string` |
| `clientSecret` | `string` |
| `scope?` | `string`[] |
| `audience?` | `string` |
| `userContext?` | `Record`\<`string`, `any`\> |

###### Returns

`Promise`\<
  \| [`ErrorOAuth2`](recipe-oauth2provider-types#erroroauth2)
  \| [`TokenInfo`](recipe-oauth2provider-types#tokeninfo)\>

##### deleteOAuth2Client()

```ts check=false reason="Generated API signature"
static deleteOAuth2Client(input, userContext?): Promise<
  | {
  status: "OK";
}
  | {
  error: string;
  errorDescription: string;
  status: "ERROR";
}>;
```

Defined in: [recipe/oauth2provider/index.ts:55](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/oauth2provider/index.ts#L55)

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `input` | [`DeleteOAuth2ClientInput`](recipe-oauth2provider-types#deleteoauth2clientinput) |
| `userContext?` | `Record`\<`string`, `any`\> |

###### Returns

`Promise`\<
  \| \{
  `status`: `"OK"`;
\}
  \| \{
  `error`: `string`;
  `errorDescription`: `string`;
  `status`: `"ERROR"`;
\}\>

##### getOAuth2Client()

```ts check=false reason="Generated API signature"
static getOAuth2Client(clientId, userContext?): Promise<
  | {
  client: OAuth2Client;
  status: "OK";
}
  | {
  error: string;
  errorDescription: string;
  status: "ERROR";
}>;
```

Defined in: [recipe/oauth2provider/index.ts:31](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/oauth2provider/index.ts#L31)

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `clientId` | `string` |
| `userContext?` | `Record`\<`string`, `any`\> |

###### Returns

`Promise`\<
  \| \{
  `client`: `OAuth2Client`;
  `status`: `"OK"`;
\}
  \| \{
  `error`: `string`;
  `errorDescription`: `string`;
  `status`: `"ERROR"`;
\}\>

##### getOAuth2Clients()

```ts check=false reason="Generated API signature"
static getOAuth2Clients(input, userContext?): Promise<
  | {
  clients: OAuth2Client[];
  nextPaginationToken?: string;
  status: "OK";
}
  | {
  error: string;
  errorDescription: string;
  status: "ERROR";
}>;
```

Defined in: [recipe/oauth2provider/index.ts:37](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/oauth2provider/index.ts#L37)

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `input` | [`GetOAuth2ClientsInput`](recipe-oauth2provider-types#getoauth2clientsinput) |
| `userContext?` | `Record`\<`string`, `any`\> |

###### Returns

`Promise`\<
  \| \{
  `clients`: `OAuth2Client`[];
  `nextPaginationToken?`: `string`;
  `status`: `"OK"`;
\}
  \| \{
  `error`: `string`;
  `errorDescription`: `string`;
  `status`: `"ERROR"`;
\}\>

##### revokeToken()

```ts check=false reason="Generated API signature"
static revokeToken(
   token, 
   clientId, 
   clientSecret?, 
   userContext?): Promise<
  | ErrorOAuth2
  | {
  status: "OK";
}>;
```

Defined in: [recipe/oauth2provider/index.ts:99](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/oauth2provider/index.ts#L99)

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `token` | `string` |
| `clientId` | `string` |
| `clientSecret?` | `string` |
| `userContext?` | `Record`\<`string`, `any`\> |

###### Returns

`Promise`\<
  \| [`ErrorOAuth2`](recipe-oauth2provider-types#erroroauth2)
  \| \{
  `status`: `"OK"`;
\}\>

##### revokeTokensByClientId()

```ts check=false reason="Generated API signature"
static revokeTokensByClientId(clientId, userContext?): Promise<{
  status: "OK";
}>;
```

Defined in: [recipe/oauth2provider/index.ts:140](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/oauth2provider/index.ts#L140)

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `clientId` | `string` |
| `userContext?` | `Record`\<`string`, `any`\> |

###### Returns

`Promise`\<\{
  `status`: `"OK"`;
\}\>

##### revokeTokensBySessionHandle()

```ts check=false reason="Generated API signature"
static revokeTokensBySessionHandle(sessionHandle, userContext?): Promise<{
  status: "OK";
}>;
```

Defined in: [recipe/oauth2provider/index.ts:147](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/oauth2provider/index.ts#L147)

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `sessionHandle` | `string` |
| `userContext?` | `Record`\<`string`, `any`\> |

###### Returns

`Promise`\<\{
  `status`: `"OK"`;
\}\>

##### updateOAuth2Client()

```ts check=false reason="Generated API signature"
static updateOAuth2Client(input, userContext?): Promise<
  | {
  client: OAuth2Client;
  status: "OK";
}
  | {
  error: string;
  errorDescription: string;
  status: "ERROR";
}>;
```

Defined in: [recipe/oauth2provider/index.ts:49](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/oauth2provider/index.ts#L49)

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `input` | [`UpdateOAuth2ClientInput`](recipe-oauth2provider-types#updateoauth2clientinput) |
| `userContext?` | `Record`\<`string`, `any`\> |

###### Returns

`Promise`\<
  \| \{
  `client`: `OAuth2Client`;
  `status`: `"OK"`;
\}
  \| \{
  `error`: `string`;
  `errorDescription`: `string`;
  `status`: `"ERROR"`;
\}\>

##### validateOAuth2AccessToken()

```ts check=false reason="Generated API signature"
static validateOAuth2AccessToken(
   token, 
   requirements?, 
   checkDatabase?, 
   userContext?): Promise<{
  payload: JSONObject;
  status: "OK";
}>;
```

Defined in: [recipe/oauth2provider/index.ts:62](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/oauth2provider/index.ts#L62)

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `token` | `string` |
| `requirements?` | \{ `audience?`: `string`; `clientId?`: `string`; `scopes?`: `string`[]; \} |
| `requirements.audience?` | `string` |
| `requirements.clientId?` | `string` |
| `requirements.scopes?` | `string`[] |
| `checkDatabase?` | `boolean` |
| `userContext?` | `Record`\<`string`, `any`\> |

###### Returns

`Promise`\<\{
  `payload`: [`JSONObject`](types#jsonobject);
  `status`: `"OK"`;
\}\>

##### validateOAuth2RefreshToken()

```ts check=false reason="Generated API signature"
static validateOAuth2RefreshToken(
   token, 
   scopes?, 
   userContext?): Promise<
  | InstrospectTokenResponse & { status: "OK"; }
| ErrorOAuth2>;
```

Defined in: [recipe/oauth2provider/index.ts:154](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/oauth2provider/index.ts#L154)

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `token` | `string` |
| `scopes?` | `string`[] |
| `userContext?` | `Record`\<`string`, `any`\> |

###### Returns

`Promise`\<
  \| InstrospectTokenResponse & \{ status: "OK"; \}
  \| [`ErrorOAuth2`](recipe-oauth2provider-types#erroroauth2)\>

## Variables

### createOAuth2Client()

```ts check=false reason="Generated API signature"
createOAuth2Client: (input, userContext?) => Promise<
  | {
  client: OAuth2Client;
  status: "OK";
}
  | {
  error: string;
  errorDescription: string;
  status: "ERROR";
}> = Wrapper.createOAuth2Client;
```

Defined in: [recipe/oauth2provider/index.ts:168](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/oauth2provider/index.ts#L168)

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `input` | [`CreateOAuth2ClientInput`](recipe-oauth2provider-types#createoauth2clientinput) |
| `userContext?` | `Record`\<`string`, `any`\> |

#### Returns

`Promise`\<
  \| \{
  `client`: `OAuth2Client`;
  `status`: `"OK"`;
\}
  \| \{
  `error`: `string`;
  `errorDescription`: `string`;
  `status`: `"ERROR"`;
\}\>

***

### createTokenForClientCredentials()

```ts check=false reason="Generated API signature"
createTokenForClientCredentials: (clientId, clientSecret, scope?, audience?, userContext?) => Promise<
  | ErrorOAuth2
  | TokenInfo> = Wrapper.createTokenForClientCredentials;
```

Defined in: [recipe/oauth2provider/index.ts:177](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/oauth2provider/index.ts#L177)

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `clientId` | `string` |
| `clientSecret` | `string` |
| `scope?` | `string`[] |
| `audience?` | `string` |
| `userContext?` | `Record`\<`string`, `any`\> |

#### Returns

`Promise`\<
  \| [`ErrorOAuth2`](recipe-oauth2provider-types#erroroauth2)
  \| [`TokenInfo`](recipe-oauth2provider-types#tokeninfo)\>

***

### deleteOAuth2Client()

```ts check=false reason="Generated API signature"
deleteOAuth2Client: (input, userContext?) => Promise<
  | {
  status: "OK";
}
  | {
  error: string;
  errorDescription: string;
  status: "ERROR";
}> = Wrapper.deleteOAuth2Client;
```

Defined in: [recipe/oauth2provider/index.ts:172](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/oauth2provider/index.ts#L172)

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `input` | [`DeleteOAuth2ClientInput`](recipe-oauth2provider-types#deleteoauth2clientinput) |
| `userContext?` | `Record`\<`string`, `any`\> |

#### Returns

`Promise`\<
  \| \{
  `status`: `"OK"`;
\}
  \| \{
  `error`: `string`;
  `errorDescription`: `string`;
  `status`: `"ERROR"`;
\}\>

***

### getOAuth2Client()

```ts check=false reason="Generated API signature"
getOAuth2Client: (clientId, userContext?) => Promise<
  | {
  client: OAuth2Client;
  status: "OK";
}
  | {
  error: string;
  errorDescription: string;
  status: "ERROR";
}> = Wrapper.getOAuth2Client;
```

Defined in: [recipe/oauth2provider/index.ts:165](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/oauth2provider/index.ts#L165)

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `clientId` | `string` |
| `userContext?` | `Record`\<`string`, `any`\> |

#### Returns

`Promise`\<
  \| \{
  `client`: `OAuth2Client`;
  `status`: `"OK"`;
\}
  \| \{
  `error`: `string`;
  `errorDescription`: `string`;
  `status`: `"ERROR"`;
\}\>

***

### getOAuth2Clients()

```ts check=false reason="Generated API signature"
getOAuth2Clients: (input, userContext?) => Promise<
  | {
  clients: OAuth2Client[];
  nextPaginationToken?: string;
  status: "OK";
}
  | {
  error: string;
  errorDescription: string;
  status: "ERROR";
}> = Wrapper.getOAuth2Clients;
```

Defined in: [recipe/oauth2provider/index.ts:166](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/oauth2provider/index.ts#L166)

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `input` | [`GetOAuth2ClientsInput`](recipe-oauth2provider-types#getoauth2clientsinput) |
| `userContext?` | `Record`\<`string`, `any`\> |

#### Returns

`Promise`\<
  \| \{
  `clients`: `OAuth2Client`[];
  `nextPaginationToken?`: `string`;
  `status`: `"OK"`;
\}
  \| \{
  `error`: `string`;
  `errorDescription`: `string`;
  `status`: `"ERROR"`;
\}\>

***

### init()

```ts check=false reason="Generated API signature"
init: (config?) => RecipeListFunction = Wrapper.init;
```

Defined in: [recipe/oauth2provider/index.ts:163](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/oauth2provider/index.ts#L163)

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `config?` | [`TypeInput`](recipe-oauth2provider-types#typeinput) |

#### Returns

[`RecipeListFunction`](types#recipelistfunction)

***

### revokeToken()

```ts check=false reason="Generated API signature"
revokeToken: (token, clientId, clientSecret?, userContext?) => Promise<
  | ErrorOAuth2
  | {
  status: "OK";
}> = Wrapper.revokeToken;
```

Defined in: [recipe/oauth2provider/index.ts:179](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/oauth2provider/index.ts#L179)

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `token` | `string` |
| `clientId` | `string` |
| `clientSecret?` | `string` |
| `userContext?` | `Record`\<`string`, `any`\> |

#### Returns

`Promise`\<
  \| [`ErrorOAuth2`](recipe-oauth2provider-types#erroroauth2)
  \| \{
  `status`: `"OK"`;
\}\>

***

### revokeTokensByClientId()

```ts check=false reason="Generated API signature"
revokeTokensByClientId: (clientId, userContext?) => Promise<{
  status: "OK";
}> = Wrapper.revokeTokensByClientId;
```

Defined in: [recipe/oauth2provider/index.ts:180](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/oauth2provider/index.ts#L180)

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `clientId` | `string` |
| `userContext?` | `Record`\<`string`, `any`\> |

#### Returns

`Promise`\<\{
  `status`: `"OK"`;
\}\>

***

### revokeTokensBySessionHandle()

```ts check=false reason="Generated API signature"
revokeTokensBySessionHandle: (sessionHandle, userContext?) => Promise<{
  status: "OK";
}> = Wrapper.revokeTokensBySessionHandle;
```

Defined in: [recipe/oauth2provider/index.ts:181](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/oauth2provider/index.ts#L181)

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `sessionHandle` | `string` |
| `userContext?` | `Record`\<`string`, `any`\> |

#### Returns

`Promise`\<\{
  `status`: `"OK"`;
\}\>

***

### updateOAuth2Client()

```ts check=false reason="Generated API signature"
updateOAuth2Client: (input, userContext?) => Promise<
  | {
  client: OAuth2Client;
  status: "OK";
}
  | {
  error: string;
  errorDescription: string;
  status: "ERROR";
}> = Wrapper.updateOAuth2Client;
```

Defined in: [recipe/oauth2provider/index.ts:170](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/oauth2provider/index.ts#L170)

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `input` | [`UpdateOAuth2ClientInput`](recipe-oauth2provider-types#updateoauth2clientinput) |
| `userContext?` | `Record`\<`string`, `any`\> |

#### Returns

`Promise`\<
  \| \{
  `client`: `OAuth2Client`;
  `status`: `"OK"`;
\}
  \| \{
  `error`: `string`;
  `errorDescription`: `string`;
  `status`: `"ERROR"`;
\}\>

***

### validateOAuth2AccessToken()

```ts check=false reason="Generated API signature"
validateOAuth2AccessToken: (token, requirements?, checkDatabase?, userContext?) => Promise<{
  payload: JSONObject;
  status: "OK";
}> = Wrapper.validateOAuth2AccessToken;
```

Defined in: [recipe/oauth2provider/index.ts:174](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/oauth2provider/index.ts#L174)

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `token` | `string` |
| `requirements?` | \{ `audience?`: `string`; `clientId?`: `string`; `scopes?`: `string`[]; \} |
| `requirements.audience?` | `string` |
| `requirements.clientId?` | `string` |
| `requirements.scopes?` | `string`[] |
| `checkDatabase?` | `boolean` |
| `userContext?` | `Record`\<`string`, `any`\> |

#### Returns

`Promise`\<\{
  `payload`: [`JSONObject`](types#jsonobject);
  `status`: `"OK"`;
\}\>

***

### validateOAuth2RefreshToken()

```ts check=false reason="Generated API signature"
validateOAuth2RefreshToken: (token, scopes?, userContext?) => Promise<
  | InstrospectTokenResponse & { status: "OK"; }
  | ErrorOAuth2> = Wrapper.validateOAuth2RefreshToken;
```

Defined in: [recipe/oauth2provider/index.ts:175](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/oauth2provider/index.ts#L175)

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `token` | `string` |
| `scopes?` | `string`[] |
| `userContext?` | `Record`\<`string`, `any`\> |

#### Returns

`Promise`\<
  \| InstrospectTokenResponse & \{ status: "OK"; \}
  \| [`ErrorOAuth2`](recipe-oauth2provider-types#erroroauth2)\>

## References

### APIInterface

Re-exports [APIInterface](recipe-oauth2provider-types#apiinterface)

***

### APIOptions

Re-exports [APIOptions](recipe-oauth2provider-types#apioptions)

***

### RecipeInterface

Re-exports [RecipeInterface](recipe-oauth2provider-types#recipeinterface)
