From c9fae15b87ea40719f10061728e84753f400e903 Mon Sep 17 00:00:00 2001 From: Danny Purcell Date: Mon, 15 Jan 2024 23:41:10 -0600 Subject: [PATCH 1/2] Update SupaSocialsAuth to pass scopes and query params to signInWithOAuth Allows for triggering consent prompts. --- lib/src/components/supa_socials_auth.dart | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/src/components/supa_socials_auth.dart b/lib/src/components/supa_socials_auth.dart index 47bf4ef..9525eb7 100644 --- a/lib/src/components/supa_socials_auth.dart +++ b/lib/src/components/supa_socials_auth.dart @@ -85,6 +85,12 @@ class SupaSocialsAuth extends StatefulWidget { /// Whether to show a SnackBar after a successful sign in final bool showSuccessSnackBar; + /// OpenID scope(s) for provider authorization request (ex. '.default') + final String? scopes; + + /// Parameters to include in provider authorization request (ex. {'prompt': 'consent'}) + final Map? queryParams; + const SupaSocialsAuth({ Key? key, required this.socialProviders, @@ -94,6 +100,8 @@ class SupaSocialsAuth extends StatefulWidget { this.onError, this.socialButtonVariant = SocialButtonVariant.iconAndText, this.showSuccessSnackBar = true, + this.scopes, + this.queryParams, }) : super(key: key); @override @@ -209,6 +217,8 @@ class _SupaSocialsAuthState extends State { await supabase.auth.signInWithOAuth( socialProvider, redirectTo: widget.redirectUrl, + scopes: widget.scopes, + queryParams: widget.queryParams, ); } on AuthException catch (error) { if (widget.onError == null && context.mounted) { From 1f2ae38632ecdffe25b77426c3a21b02d46b5b53 Mon Sep 17 00:00:00 2001 From: dshukertjr Date: Tue, 23 Jan 2024 16:27:48 +0900 Subject: [PATCH 2/2] Change the type of the scopes and queryParams so that different values can be passed for each providers --- lib/src/components/supa_socials_auth.dart | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/src/components/supa_socials_auth.dart b/lib/src/components/supa_socials_auth.dart index 9525eb7..d0d9d4e 100644 --- a/lib/src/components/supa_socials_auth.dart +++ b/lib/src/components/supa_socials_auth.dart @@ -86,10 +86,10 @@ class SupaSocialsAuth extends StatefulWidget { final bool showSuccessSnackBar; /// OpenID scope(s) for provider authorization request (ex. '.default') - final String? scopes; + final Map? scopes; /// Parameters to include in provider authorization request (ex. {'prompt': 'consent'}) - final Map? queryParams; + final Map>? queryParams; const SupaSocialsAuth({ Key? key, @@ -217,8 +217,8 @@ class _SupaSocialsAuthState extends State { await supabase.auth.signInWithOAuth( socialProvider, redirectTo: widget.redirectUrl, - scopes: widget.scopes, - queryParams: widget.queryParams, + scopes: widget.scopes?[socialProvider], + queryParams: widget.queryParams?[socialProvider], ); } on AuthException catch (error) { if (widget.onError == null && context.mounted) {