Skip to content

Update SupaSocialsAuth to pass scopes and query params to signInWithOAuth #71

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions lib/src/components/supa_socials_auth.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 Map<OAuthProvider, String>? scopes;

/// Parameters to include in provider authorization request (ex. {'prompt': 'consent'})
final Map<OAuthProvider, Map<String, String>>? queryParams;

const SupaSocialsAuth({
Key? key,
required this.socialProviders,
Expand All @@ -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
Expand Down Expand Up @@ -209,6 +217,8 @@ class _SupaSocialsAuthState extends State<SupaSocialsAuth> {
await supabase.auth.signInWithOAuth(
socialProvider,
redirectTo: widget.redirectUrl,
scopes: widget.scopes?[socialProvider],
queryParams: widget.queryParams?[socialProvider],
);
} on AuthException catch (error) {
if (widget.onError == null && context.mounted) {
Expand Down