Skip to main content

OAuthApplication

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

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

Methods

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
  • Name
    clientId
    Type
    string
    Description

    The OAuth client_id from the authorize request.

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

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>
  • Name
    oauthClientId
    Type
    string
    Description

    The OAuth client_id from the authorize request.

  • Name
    scope?
    Type
    string
    Description

    A space-delimited scope string from the authorize request.

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

Feedback

What did you think of this content?

Last updated on