diff --git a/.changeset/fix-oauth-consent-redirect.md b/.changeset/fix-oauth-consent-redirect.md
new file mode 100644
index 00000000000..d1b82f62373
--- /dev/null
+++ b/.changeset/fix-oauth-consent-redirect.md
@@ -0,0 +1,5 @@
+---
+'@clerk/ui': patch
+---
+
+Fix OAuthConsent always redirecting to sign-in by adopting the `AuthenticatedRoutes` pattern used by other full-page components
diff --git a/packages/ui/src/components/OAuthConsent/OAuthConsent.tsx b/packages/ui/src/components/OAuthConsent/OAuthConsent.tsx
index 430d8779103..6802e665807 100644
--- a/packages/ui/src/components/OAuthConsent/OAuthConsent.tsx
+++ b/packages/ui/src/components/OAuthConsent/OAuthConsent.tsx
@@ -10,6 +10,7 @@ import { Header } from '@/ui/elements/Header';
import { LoadingCardContainer } from '@/ui/elements/LoadingCard';
import { Modal } from '@/ui/elements/Modal';
import { Alert, Textarea } from '@/ui/primitives';
+import { Route, Switch } from '@/ui/router';
import { InlineAction } from './InlineAction';
import {
@@ -94,41 +95,35 @@ function _OAuthConsent() {
if (errorMessage) {
return (
-
-
-
- {errorMessage}
-
-
-
-
+
+
+ {errorMessage}
+
+
+
);
}
if (isLoading) {
return (
-
-
-
-
-
-
-
-
- );
- }
- }
-
- if (ctx.enableOrgSelection && (!isMembershipsLoaded || userMemberships.isLoading)) {
- return (
-
-
+ );
+ }
+ }
+
+ if (ctx.enableOrgSelection && (!isMembershipsLoaded || userMemberships.isLoading)) {
+ return (
+
+
+
+
+
+
);
}
@@ -155,7 +150,7 @@ function _OAuthConsent() {
const hasOfflineAccess = scopes.some(item => item.scope === OFFLINE_ACCESS_SCOPE);
return (
-
+ <>
-
+ >
);
}
@@ -373,4 +368,20 @@ function RedirectUriModal({ onOpen, onClose, isOpen, redirectUri, oauthApplicati
);
}
-export const OAuthConsent = withCoreUserGuard(withCardStateProvider(_OAuthConsent));
+const AuthenticatedRoutes = withCoreUserGuard(withCardStateProvider(_OAuthConsent));
+
+const OAuthConsentInternal = () => {
+ return (
+
+
+
+
+
+
+
+
+
+ );
+};
+
+export const OAuthConsent = OAuthConsentInternal;
diff --git a/packages/ui/src/components/OAuthConsent/__tests__/OAuthConsent.test.tsx b/packages/ui/src/components/OAuthConsent/__tests__/OAuthConsent.test.tsx
index 911ef36327f..643e74d1a1d 100644
--- a/packages/ui/src/components/OAuthConsent/__tests__/OAuthConsent.test.tsx
+++ b/packages/ui/src/components/OAuthConsent/__tests__/OAuthConsent.test.tsx
@@ -181,9 +181,9 @@ describe('OAuthConsent', () => {
const getConsentInfo = vi.fn().mockResolvedValue(fakeConsentInfo);
mockOAuthApplication(fixtures.clerk, { getConsentInfo });
- const { container } = render(, { wrapper });
+ const { queryByText } = render(, { wrapper });
- expect(container.firstChild).toBeNull();
+ expect(queryByText('Clerk CLI')).toBeNull();
expect(getConsentInfo).not.toHaveBeenCalled();
});