OAuthApplication - Types - Next.js | Clerk Docs

OAuthApplication

The OAuthApplication object provides helpers for building custom OAuth consent flows in Clerk.

Use this object together with the useOAuthConsent() hook or the component when you need to render a custom consent page for an OAuth application.

Methods

buildConsentActionUrl()

Returns the URL to use as the action attribute of your consent form. Clerk includes the current session context automatically, including _clerk_session_id and, in development, the dev browser JWT.

function buildConsentActionUrl(params: { clientId: string }): string

Parameters

Example

const actionUrl = clerk.oauthApplication.buildConsentActionUrl({
  clientId,
})

getConsentInfo()

Loads the consent metadata for a signed-in user and OAuth application. Returns a OAuthConsentInfo object.

Use this method when you want to build your own consent UI without the useOAuthConsent() hook.

function getConsentInfo(params: GetOAuthConsentInfoParams): Promise<OAuthConsentInfo>

GetOAuthConsentInfoParams

Example

const consentInfo = await clerk.oauthApplication.getConsentInfo({
  oauthClientId: clientId,
  scope,
})