Draft
Conversation
because when the SSO button is used in an OAuth App (3rd party integration) flow, the user must be redirected to the consent page / 3rd party callback page. (This is a little confusing because the OAuth app here is not the same as the OAuth provider/strategy for the SSO button)
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
7ea82c5 to
7483857
Compare
7483857 to
2c13d13
Compare
In clerk.ts, the handleRedirectCallback method creates a RedirectUrls instance like this:
const redirectUrls = new RedirectUrls(this.#options, params);
But the RedirectUrls constructor expects search params as the third argument:
constructor(options: ClerkOptions, props: RedirectOptions = {}, searchParams: any = {}, mode?: ComponentMode)
Since no searchParams is passed, the redirect_url from the URL query string is never read. The code falls through to the default '/'.
The Fix
The SSO callback page must:
Read redirect parameters from the URL using useSearchParams()
Pass them as props to <AuthenticateWithRedirectCallback>
The key change in the SSO callback page:
const searchParams = useSearchParams()const redirectUrl = searchParams.get('redirect_url') ?? undefinedconst signInFallbackRedirectUrl = searchParams.get('sign_in_fallback_redirect_url') ?? undefined// ... etcreturn ( <AuthenticateWithRedirectCallback redirectUrl={redirectUrl} signInFallbackRedirectUrl={signInFallbackRedirectUrl} // ... etc />)
This ensures the redirect parameters are passed to handleRedirectCallback via component props, where they get picked up by RedirectUrls through fromProps instead of the missing fromSearchParams.
particularly assuming clerk/javascript@cea6727
Closed
9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
because when the SSO button is used in an OAuth App (3rd party integration) flow, the user must be redirected to the consent page / 3rd party callback page. (This is a little confusing because the OAuth app here is not the same as the OAuth provider/strategy for the SSO button)
🔎 Previews:
What does this solve?
What changed?