Skip to content

Add custom OAuth consent page docs#3412

Closed
jescalan wants to merge 1 commit into
mainfrom
je/docs-oauth-custom-consent-page
Closed

Add custom OAuth consent page docs#3412
jescalan wants to merge 1 commit into
mainfrom
je/docs-oauth-custom-consent-page

Conversation

@jescalan
Copy link
Copy Markdown
Contributor

@jescalan jescalan commented Jun 1, 2026

Summary

Adds documentation for configuring a custom OAuth consent page, with a strong recommendation to use the default Account Portal page or Clerk prebuilt OAuthConsent component instead of a fully custom flow. The guide explains the phishing and token-grant risks, redirect URI presentation requirements, safe route configuration, and low-level custom-flow responsibilities when a custom implementation is unavoidable.

Changes in this repo

Adds a new custom OAuth consent page guide, an OAuthConsent component reference page, framework-specific prebuilt and custom-flow snippets, navigation entries, and cross-links from existing OAuth docs.

Preview links

New pages:

Changed sections:

@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 1, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
clerk-docs Ready Ready Preview Jun 1, 2026 10:16pm

Request Review

@jescalan jescalan requested review from jfoshee and wobsoriano June 1, 2026 21:57
@jescalan jescalan marked this pull request as ready for review June 1, 2026 21:57
@jescalan jescalan requested a review from a team as a code owner June 1, 2026 21:57
@SarahSoutoul
Copy link
Copy Markdown
Contributor

@jescalan I think there may be some overlap with this PR from @wobsoriano

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5cfba6f380

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +66 to +68
{Array.from(searchParams.entries()).map(([key, value], index) => (
<input key={`${key}:${index}`} type="hidden" name={key} value={value} />
))}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Omit query-supplied decision fields

If a malicious authorization URL reaches this custom consent route with a query parameter like consented=true, this loop renders it as a hidden input before the clicked submit button, so the POST body contains both the attacker-supplied value and the user's Allow/Deny value. Any parser that reads the first form value, such as FormData.get(), would treat a user clicking Deny as consent; whitelist the OAuth authorization parameters to preserve and exclude reserved form fields like consented (and apply the same fix to the repeated snippets).

Useful? React with 👍 / 👎.

---
title: '`<OAuthConsent />` component'
description: Clerk's <OAuthConsent /> component renders a consent screen for OAuth provider flows.
sdk: astro, nextjs, nuxt, react, react-router, tanstack-react-start, vue
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Add js-frontend to OAuthConsent docs

The shared Clerk reference already exposes mountOAuthConsent and unmountOAuthConsent on Clerk, but this frontmatter omits js-frontend, so the SDK selector/search will hide the new OAuthConsent reference page from JavaScript Frontend users even though they have the public mounting API for this component. Include js-frontend and document the mount/unmount usage as the other component reference pages do.

Useful? React with 👍 / 👎.

Comment on lines +23 to +27
export function OAuthConsentPage() {
return (
<Show when="signed-in">
<OAuthConsent />
</Show>
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Include the required referrer policy in React examples

These React, React Router, and TanStack snippets are presented as copy-paste custom consent routes, but unlike the Next/Astro/Nuxt examples they never set strict-origin-when-cross-origin even though this guide says that policy is required because the form posts to Clerk's Frontend API and can otherwise be rejected with Origin: null. Users following these snippets directly can end up with consent submissions that fail in the affected SPA/framework routes; add the same <meta name="referrer" ...>/head configuration to each example.

Useful? React with 👍 / 👎.

```tsx {{ filename: 'app/oauth-consent/custom-consent-form.tsx' }}
'use client'

import { useClerk, useOAuthConsent } from '@clerk/nextjs'
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Use the documented hook import path

The generated reference for useOAuthConsent() in this repo documents the hook as imported from @clerk/react/internal, while this new custom-flow snippet imports it from the public framework package; the same pattern is repeated for React Router and TanStack. If customers copy these examples with the currently documented exports, TypeScript/module resolution fails before the consent page can render, so the snippets should use an available import path or the package references need to be updated to expose the hook publicly.

Useful? React with 👍 / 👎.


return (
<form method="POST" action={clerk.oauthApplication.buildConsentActionUrl({ clientId })}>
<h1>{data.oauthApplicationName} wants access to your account</h1>
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Show all required consent identity fields

For customers who copy the low-level custom-flow examples, the rendered consent surface only shows the OAuth app name/logo plus scopes and redirect host, even though the guide's required work also includes the OAuth application URL, client ID, resource service, and signed-in user. Omitting those fields makes the sample weaker than the security requirements it documents and can lead custom pages to ship without enough identity context for users to distinguish a legitimate client from an impersonating one; add these fields to each repeated snippet or avoid presenting the sample as the minimum shape.

Useful? React with 👍 / 👎.

@jfoshee
Copy link
Copy Markdown
Contributor

jfoshee commented Jun 2, 2026

Superseded by #3413

@jfoshee jfoshee closed this Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants