Skip to content

(WIP) Document OAuth applications JS Backend SDK endpoints #2447

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions docs/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3105,6 +3105,44 @@
]
]
},
{
"title": "OAuth applications",
"collapse": true,
"items": [
[
{
"title": "`list()`",
"wrap": false,
"href": "/docs/references/backend/oauth-applications/get-oauth-application-list"
},
{
"title": "`get()`",
"wrap": false,
"href": "/docs/references/backend/oauth-applications/get-oauth-application"
},
{
"title": "`create()`",
"wrap": false,
"href": "/docs/references/backend/oauth-applications/create-oauth-application"
},
{
"title": "`update()`",
"wrap": false,
"href": "/docs/references/backend/oauth-applications/update-oauth-application"
},
{
"title": "`delete()`",
"wrap": false,
"href": "/docs/references/backend/oauth-applications/delete-oauth-application"
},
{
"title": "`rotateSecret()`",
"wrap": false,
"href": "/docs/references/backend/oauth-applications/rotate-secret"
}
]
]
},
{
"title": "`authenticateRequest()`",
"wrap": false,
Expand Down Expand Up @@ -3153,6 +3191,10 @@
"title": "Backend `Invitation` object",
"href": "/docs/references/backend/types/backend-invitation"
},
{
"title": "Backend `OAuthApplication` object",
"href": "/docs/references/backend/types/backend-oauth-application"
},
{
"title": "Backend `Organization` object",
"href": "/docs/references/backend/types/backend-organization"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
---
title: '`create()`'
description: Use Clerk's Backend SDK to create an OAuth application.
---

Creates a new [`OAuthApplication`](/docs/references/backend/types/backend-oauth-application) with the given name and callback URL for an instance.

```ts
function create(params: CreateOAuthApplicationParams): Promise<OAuthApplication>
```

## `CreateOAuthApplicationParams`

<Properties>
- `name` (required)
- `string`

The name of the new OAuth application.

---

- `redirectUris?`
- `string[] | null`

An array of redirect URIs of the new OAuth application.

---

- `scopes?`
- `string | null`

Scopes for the new OAuth application. Available scopes are `profile`, `email`, `public_metadata`, `private_metadata`. Defaults to `profile email`. Provide the requested scopes as a string, separated by spaces.

---

- `consentScreenEnabled?`
- `boolean | null`

Specifies whether the consent screen should be displayed in the authentication flow. Cannot be disabled for dynamically registered OAuth applications. Defaults to `true`.

---

- `pkceRequired?`
- `boolean | null`

Specifies whether the Proof Key of Code Exchange (PKCE) flow should be required in the authentication flow. Defaults to `false`.

---

- `public?`
- `boolean | null`

Indicates whether the client is public. If true, the Proof Key of Code Exchange (PKCE) flow can be used.
</Properties>

## Example

<Include src="_partials/backend/usage" />

```tsx
const response = await clerkClient.oauthApplications.create({
name: "oauthapp_123",
redirect_uris: [
""
],
scopes: "profile email public_metadata",
public: null
})
```

## Backend API (BAPI) endpoint

This method in the SDK is a wrapper around the BAPI endpoint `POST/oauth_applications`. See the [BAPI reference](/docs/reference/backend-api/tag/OAuth-Applications#operation/CreateOAuthApplication){{ target: '_blank' }} for more information.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
title: '`delete()`'
description: Use Clerk's Backend SDK to delete an OAuth application.
---

Deletes an [`OAuthApplication`](/docs/references/backend/types/backend-oauth-application) by its ID. Returns a [`DeletedObject`](/docs/references/javascript/types/deleted-object) object.

```ts
function delete(oauthApplicationId: string): Promise<DeletedObject>
```

## Parameters

<Properties>
- `oauthApplicationId` (required)
- `string`

The ID of the OAuth application to delete.
</Properties>

## Example

<Include src="_partials/backend/usage" />

```tsx
const oauthApplicationId = 'oauthapp_123'

const response = await clerkClient.oauthApplications.delete(oauthApplicationId)
```

## Backend API (BAPI) endpoint

This method in the SDK is a wrapper around the BAPI endpoint `DELETE/oauth_applications/{oauth_application_id}`. See the [BAPI reference](/docs/reference/backend-api/tag/OAuth-Applications#operation/DeleteOAuthApplication){{ target: '_blank' }} for more information.
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
---
title: '`list()`'
description: Use Clerk's Backend SDK to retrieve a list of OAuth applications for an instance.
---

Retrieves a list of OAuth applications for an instance. Returns a [`PaginatedResourceResponse`](/docs/references/backend/types/paginated-resource-response) object with a `data` property that contains an array of [`OAuthApplication`](/docs/references/backend/types/backend-saml-connection) objects, and a `totalCount` property that indicates the total number of OAuth applications for the instance.

```ts
function list(params: ClerkPaginationRequest = {}): Promise<PaginatedResourceResponse<OAuthApplication[]>>
```

## Parameters

<Properties>
- `limit?`
- `number`

The number of results to return. Must be an integer greater than zero and less than 501. Can be used for paginating the results together with `offset`. Defaults to `10`.

---

- `offset?`
- `number`

Skip the first `offset` results when paginating. Needs to be an integer greater or equal to zero. To be used in conjunction with `limit`. Defaults to `0`.

---

- `orderBy?`
- `'name' | 'created_at'`

Return OAuth applications in a particular order. Prefix with a `-` to reverse the order. Prefix with a `+` to list in ascending order. Defaults to `'+created_at'`.

---

- `nameQuery?`
- `string`

Filters OAuth applications with names that match the given query, via case-insensitive partial match.
</Properties>

## Examples

<Include src="_partials/backend/usage" />

### Basic

```tsx
const response = await clerkClient.oauthApplications.list();
```

### Limit the number of results

Retrieves list of OAuth applications that is filtered by the number of results.

```tsx
const { data, totalCount } = await clerkClient.oauthApplications.list({
// returns the first 10 results
limit: 10,
})
```

### Skip results

Retrieves list of OAuth applications that is filtered by the number of results to skip.

```tsx
const { data, totalCount } = await clerkClient.oauthApplications.list({
// skips the first 10 results
offset: 10,
})
```

## Backend API (BAPI) endpoint

This method in the SDK is a wrapper around the BAPI endpoint `GET/oauth_applications`. See the [BAPI reference](/docs/reference/backend-api/tag/OAuth-Applications#operation/ListOAuthApplications){{ target: '_blank' }} for more information.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
title: '`get()`'
description: Use Clerk's Backend SDK to retrieve an OAuth application.
---

Retrieves an [`OAuthApplication`](/docs/references/backend/types/backend-oauth-application) by its ID.

```ts
function get(oauthApplicationId: string): Promise<OAuthApplication>
```

## Parameters

<Properties>
- `oauthApplicationId` (required)
- `string`

The ID of the OAuth application to retrieve.
</Properties>

## Example

<Include src="_partials/backend/usage" />

```tsx
const oauthApplicationId = 'oauthapp_123'

const response = await clerkClient.oauthApplications.get(oauthApplicationId)
```

## Backend API (BAPI) endpoint

This method in the SDK is a wrapper around the BAPI endpoint `GET/oauth_applications/{oauth_application_id}`. See the [BAPI reference](/docs/reference/backend-api/tag/OAuth-Applications#operation/GetOAuthApplication){{ target: '_blank' }} for more information.
33 changes: 33 additions & 0 deletions docs/references/backend/oauth-applications/rotate-secret.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
title: '`rotateSecret()`'
description: Use Clerk's Backend SDK to rotate the OAuth application's client secret.
---

Rotates the [`OAuthApplication`](/docs/references/backend/types/backend-oauth-application)'s client secret by its ID. When the client secret is rotated, ensure that you update it in your authorized OAuth clients.

```ts
function rotateSecret(oauthApplicationId: string): Promise<OAuthApplication>
```

## Parameters

<Properties>
- `oauthApplicationId`
- `string`

The ID of the OAuth application for which to rotate the client secret.
</Properties>

## Example

<Include src="_partials/backend/usage" />

```tsx
const oauthApplicationId = 'oauthapp_123'

const response = await clerkClient.oauthApplications.rotateSecret(oauthApplicationId)
```

## Backend API (BAPI) endpoint

This method in the SDK is a wrapper around the BAPI endpoint `POST/oauth_applications/{oauth_application_id}/rotate_secret`. See the [BAPI reference](/docs/reference/backend-api/tag/OAuth-Applications#operation/RotateSecret){{ target: '_blank' }} for more information.
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
---
title: '`update()`'
description: Use Clerk's Backend SDK to update an OAuth application.
---

Updates an [`OAuthApplication`](/docs/references/backend/types/backend-oauth-application) by its ID.

```ts
function update(
params: UpdateOAuthApplicationParams,
): Promise<OAuthApplication>
```

## `UpdateOAuthApplicationParams`

<Properties>
- `oauthApplicationId` (required)
- `string`

The ID of the OAuth application to update.

---

- `name`
- `string | null`

The new name of the OAuth application.

---

- `redirectUris?`
- `string[] | null`

An array of redirect URIs of the new OAuth application.

---

- `scopes?`
- `string | null`

Scopes for the new OAuth application. Available scopes are `profile`, `email`, `public_metadata`, `private_metadata`. Defaults to `profile email`. Provide the requested scopes as a string, separated by spaces.

---

- `consentScreenEnabled?`
- `boolean | null`

Specifies whether the consent screen should be displayed in the authentication flow. Cannot be disabled for dynamically registered OAuth applications. Defaults to `true`.

---

- `pkceRequired?`
- `boolean | null`

Specifies whether the Proof Key of Code Exchange (PKCE) flow should be required in the authentication flow. Defaults to `false`.

---

- `public?`
- `boolean | null`

Indicates whether the client is public. If true, the Proof Key of Code Exchange (PKCE) flow can be used.

</Properties>

## Example

<Include src="_partials/backend/usage" />

```tsx
const oauthApplicationId = 'oauthapp_123'

const response = await clerkClient.oauthApplications.update(oauthApplicationId, {
name: 'Updated OAuth Application',
})
```

## Backend API (BAPI) endpoint

This method in the SDK is a wrapper around the BAPI endpoint `PATCH/oauth_applications/{oauth_application_id}`. See the [BAPI reference](/docs/reference/backend-api/tag/OAuth-Applications#operation/UpdateOAuthApplication){{ target: '_blank' }} for more information.
Loading
Loading