@@ -97,6 +97,7 @@ class ClerkAuthState extends clerk.Auth with ChangeNotifier {
9797 routeSettings: const RouteSettings (name: _kSsoRouteName),
9898 builder: (BuildContext context) {
9999 return _SsoWebViewOverlay (
100+ strategy: strategy,
100101 url: url,
101102 oauthRedirect: clerk.ClerkConstants .oauthRedirect,
102103 onError: (error) => _onError (error, onError),
@@ -138,6 +139,7 @@ class ClerkAuthState extends clerk.Auth with ChangeNotifier {
138139 useRootNavigator: true ,
139140 routeSettings: const RouteSettings (name: _kSsoRouteName),
140141 builder: (context) => _SsoWebViewOverlay (
142+ strategy: strategy,
141143 url: url,
142144 oauthRedirect: clerk.ClerkConstants .oauthRedirect,
143145 onError: (error) => _onError (error, onError),
@@ -265,11 +267,13 @@ class ClerkAuthState extends clerk.Auth with ChangeNotifier {
265267
266268class _SsoWebViewOverlay extends StatefulWidget {
267269 const _SsoWebViewOverlay ({
270+ required this .strategy,
268271 required this .url,
269272 required this .oauthRedirect,
270273 required this .onError,
271274 });
272275
276+ final clerk.Strategy strategy;
273277 final String url;
274278 final String oauthRedirect;
275279 final ClerkErrorCallback onError;
@@ -287,9 +291,6 @@ class _SsoWebViewOverlayState extends State<_SsoWebViewOverlay> {
287291 super .initState ();
288292
289293 controller = WebViewController ()
290- ..setUserAgent (
291- 'Clerk Flutter SDK v${clerk .ClerkConstants .flutterSdkVersion }' ,
292- )
293294 ..setJavaScriptMode (JavaScriptMode .unrestricted)
294295 ..setBackgroundColor (Colors .white)
295296 ..setNavigationDelegate (
@@ -319,7 +320,23 @@ class _SsoWebViewOverlayState extends State<_SsoWebViewOverlay> {
319320 },
320321 ),
321322 );
322- controller.loadRequest (Uri .parse (widget.url));
323+
324+ // For google authentication we use a custom user-agent
325+ if (widget.strategy.provider == clerk.Strategy .oauthGoogle.provider) {
326+ controller.setUserAgent (clerk.ClerkConstants .userAgent);
327+ controller.loadRequest (Uri .parse (widget.url));
328+ } else {
329+ controller.getUserAgent ().then ((String ? userAgent) {
330+ if (mounted) {
331+ if (userAgent != null ) {
332+ controller.setUserAgent (
333+ '$userAgent ${clerk .ClerkConstants .userAgent }' ,
334+ );
335+ }
336+ controller.loadRequest (Uri .parse (widget.url));
337+ }
338+ });
339+ }
323340 }
324341
325342 @override
0 commit comments