@@ -6,6 +6,7 @@ import * as WebBrowser from 'expo-web-browser';
66import { errorThrower } from '../utils/errors' ;
77
88export type StartSSOFlowParams = {
9+ redirectUrl ?: string ;
910 unsafeMetadata ?: SignUpUnsafeMetadata ;
1011} & (
1112 | {
@@ -19,7 +20,7 @@ export type StartSSOFlowParams = {
1920
2021export type StartSSOFlowReturnType = {
2122 createdSessionId : string | null ;
22- authSessionResult ? : WebBrowser . WebBrowserAuthSessionResult ;
23+ authSessionResult : WebBrowser . WebBrowserAuthSessionResult | null ;
2324 setActive ?: SetActive ;
2425 signIn ?: SignInResource ;
2526 signUp ?: SignUpResource ;
@@ -33,6 +34,7 @@ export function useSSO() {
3334 if ( ! isSignInLoaded || ! isSignUpLoaded ) {
3435 return {
3536 createdSessionId : null ,
37+ authSessionResult : null ,
3638 signIn,
3739 signUp,
3840 setActive,
@@ -47,9 +49,11 @@ export function useSSO() {
4749 * to include the `rotating_token_nonce` on SSO callback
4850 * @ref https://clerk.com/docs/reference/backend-api/tag/Redirect-URLs#operation/CreateRedirectURL
4951 */
50- const redirectUrl = AuthSession . makeRedirectUri ( {
51- path : 'sso-callback' ,
52- } ) ;
52+ const redirectUrl =
53+ startSSOFlowParams . redirectUrl ??
54+ AuthSession . makeRedirectUri ( {
55+ path : 'sso-callback' ,
56+ } ) ;
5357
5458 await signIn . create ( {
5559 strategy,
@@ -62,13 +66,17 @@ export function useSSO() {
6266 return errorThrower . throw ( 'Missing external verification redirect URL for SSO flow' ) ;
6367 }
6468
65- const authSessionResult = await WebBrowser . openAuthSessionAsync ( externalVerificationRedirectURL . toString ( ) ) ;
69+ const authSessionResult = await WebBrowser . openAuthSessionAsync (
70+ externalVerificationRedirectURL . toString ( ) ,
71+ redirectUrl ,
72+ ) ;
6673 if ( authSessionResult . type !== 'success' || ! authSessionResult . url ) {
6774 return {
6875 createdSessionId : null ,
6976 setActive,
7077 signIn,
7178 signUp,
79+ authSessionResult,
7280 } ;
7381 }
7482
@@ -89,6 +97,7 @@ export function useSSO() {
8997 setActive,
9098 signIn,
9199 signUp,
100+ authSessionResult,
92101 } ;
93102 }
94103
0 commit comments