Use case
Standardized Auth Flow
The external browser flow feels dated / non standard in comparison to other apps and results in many browser tabs open after continued sign ins for the user. All of these tabs need to be closed by the user or else risk the user attempting to sign in again by just clicking on an existing (expired) sign in tab.
Proposal
Overview
Using a similar method as: https://pub.dev/packages/flutter_web_auth_2 would be ideal where the in app browser is used and upon sign up completion is closed directly. The user completes the full auth flow without leaving the app for an external browser
Sample Images
Android:
https://pub.dev/packages/flutter_web_auth_2/versions/4.1.0/gen-res/gen/screen-android.webp
iOS:
https://pub.dev/packages/flutter_web_auth_2/versions/4.1.0/gen-res/gen/screen-ios.webp
Implementation
clerk_flutter/lib/src/utils/clerk_auth_config.dart
ClerkAuthConfig({
required super.publishableKey,
super.sessionTokenPolling,
super.isTestMode,
super.telemetryEndpoint,
super.telemetryPeriod,
super.clientRefreshPeriod,
super.httpService,
super.httpConnectionTimeout,
this.loading = defaultLoadingWidget,
this.redirectionGenerator,
this.deepLinkStream,
this.launchExternalBrowser = false, // Add flag here for switching from default behaviour
ClerkFileCache? fileCache,
ClerkSdkLocalizationsCollection? localizations,
ClerkSdkLocalizations? fallbackLocalization,
ClerkSdkGrammarCollection? grammars,
ClerkSdkGrammar? fallbackGrammar,
clerk.Persistor? persistor,
ClerkSdkFlags flags = const ClerkSdkFlags(),
})
...
/// Whether to launch external browser for OAuth flows
final bool launchExternalBrowser;
clerk_flutter/lib/src/utils/clerk_auth_state.dart
- await launchUrl(uri, mode: LaunchMode.externalApplication);
+ await launchUrl(uri, mode: config.launchExternalBrowser ? LaunchMode.externalApplication : LaunchMode.inAppBrowserView);
3x Occurrences of these, 1 in each sso method (ssoConnect, ssoSignUp, ssoSignIn)
Along with the dart changes, modifications to the callback page <accounts url>/v1/oauth_callback are required for handling the user after success. A simple "Continue to application" button on the page that closes the window would suffice short-term with the long-term goal to auto close. This could appear even on pages that deep link from the external browser as a backup in case the user clicks cancel on the "Open in <Your App>" and are stuck on the currently blank page (having to manually navigate back their app).
Use case
Standardized Auth Flow
The external browser flow feels dated / non standard in comparison to other apps and results in many browser tabs open after continued sign ins for the user. All of these tabs need to be closed by the user or else risk the user attempting to sign in again by just clicking on an existing (expired) sign in tab.
Proposal
Overview
Using a similar method as: https://pub.dev/packages/flutter_web_auth_2 would be ideal where the in app browser is used and upon sign up completion is closed directly. The user completes the full auth flow without leaving the app for an external browser
Sample Images
Android:
https://pub.dev/packages/flutter_web_auth_2/versions/4.1.0/gen-res/gen/screen-android.webp
iOS:
https://pub.dev/packages/flutter_web_auth_2/versions/4.1.0/gen-res/gen/screen-ios.webp
Implementation
clerk_flutter/lib/src/utils/clerk_auth_config.dart
clerk_flutter/lib/src/utils/clerk_auth_state.dart
3x Occurrences of these, 1 in each sso method (ssoConnect, ssoSignUp, ssoSignIn)
Along with the dart changes, modifications to the callback page <accounts url>/v1/oauth_callback are required for handling the user after success. A simple "Continue to application" button on the page that closes the window would suffice short-term with the long-term goal to auto close. This could appear even on pages that deep link from the external browser as a backup in case the user clicks cancel on the "Open in <Your App>" and are stuck on the currently blank page (having to manually navigate back their app).