Skip to content

fix(clerk-js): include scope parameter for Consent dialog scopes#8048

Closed
jfoshee wants to merge 3 commits intomainfrom
cursor/consent-dialog-scope-parameter-db26
Closed

fix(clerk-js): include scope parameter for Consent dialog scopes#8048
jfoshee wants to merge 3 commits intomainfrom
cursor/consent-dialog-scope-parameter-db26

Conversation

@jfoshee
Copy link
Contributor

@jfoshee jfoshee commented Mar 11, 2026

Description

This PR enables the OAuthConsent component to dynamically fetch consent details from the FAPI endpoint /v1/me/oauth/consent/{client_id}. This is achieved by introducing clientId and scope as new props to the component. When clientId is provided, the component will use a new internal Clerk method (__internal_fetchOAuthConsent) to make a FAPI request, passing the scope as a query parameter.

This change supports USER-4924 by allowing the consent dialog to be populated directly from the backend based on the provided client and requested scopes. It maintains backward compatibility for existing prop-based usage when clientId is not provided. A loading state is also included while data is being fetched.

How to test:

  1. Run the sandbox app (pnpm dev:sandbox).
  2. Navigate to the OAuth consent page.
  3. Append ?client_id=<your_client_id>&scope=<space_delimited_scopes> to the URL (e.g., ?client_id=client_xxxx&scope=profile%20email) to observe the component fetching and displaying consent data.

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:
Open in Web Open in Cursor 

Add clientId and scope props to __internal_OAuthConsentProps so the
OAuthConsent component can fetch consent details from
/v1/me/oauth/consent/{client_id}?scope=<space-delimited-scopes>.

When clientId is provided, the component fetches consent data from the
FAPI endpoint. The scope prop is a space-delimited list of OAuth scopes
included as a query parameter on the request. Fetched data is merged
with any directly supplied props, maintaining backward compatibility.

Changes:
- packages/shared: Add clientId, scope to __internal_OAuthConsentProps;
  make data props optional (oAuthApplicationName, scopes, redirectUrl,
  onAllow, onDeny)
- packages/shared: Add __internal_fetchOAuthConsent to Clerk interface
- packages/clerk-js: Implement __internal_fetchOAuthConsent on Clerk
  class using the FAPI client
- packages/react: Wire __internal_fetchOAuthConsent through
  IsomorphicClerk
- packages/ui: OAuthConsent component fetches consent data when clientId
  is provided, with loading state
- packages/clerk-js/sandbox: Support client_id and scope URL params

Part of USER-4924
@cursor
Copy link

cursor bot commented Mar 11, 2026

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@changeset-bot
Copy link

changeset-bot bot commented Mar 11, 2026

🦋 Changeset detected

Latest commit: 0fb3679

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@clerk/clerk-js Patch
@clerk/chrome-extension Patch
@clerk/expo Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented Mar 11, 2026

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

Project Deployment Actions Updated (UTC)
clerk-js-sandbox Ready Ready Preview, Comment Mar 17, 2026 8:40pm

Request Review

@jfoshee jfoshee changed the title Consent dialog scope parameter fix(clerk-js): include scope parameter for Consent dialog scopes Mar 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants