diff --git a/packages/google_sign_in/google_sign_in_platform_interface/CHANGELOG.md b/packages/google_sign_in/google_sign_in_platform_interface/CHANGELOG.md index c3a7366d1937..fff5d10e5089 100644 --- a/packages/google_sign_in/google_sign_in_platform_interface/CHANGELOG.md +++ b/packages/google_sign_in/google_sign_in_platform_interface/CHANGELOG.md @@ -1,5 +1,8 @@ -## NEXT +## 2.4.0 +* Introduces: `canAccessScopes` method and `userDataEvents` stream. + * These enable separation of Authentication and Authorization, and asynchronous + sign-in operations where needed (on the web, for example!) * Updates minimum Flutter version to 3.3. * Aligns Dart and Flutter SDK constraints. diff --git a/packages/google_sign_in/google_sign_in_platform_interface/lib/google_sign_in_platform_interface.dart b/packages/google_sign_in/google_sign_in_platform_interface/lib/google_sign_in_platform_interface.dart index 64fc88d4866f..579d0f4c3c30 100644 --- a/packages/google_sign_in/google_sign_in_platform_interface/lib/google_sign_in_platform_interface.dart +++ b/packages/google_sign_in/google_sign_in_platform_interface/lib/google_sign_in_platform_interface.dart @@ -137,6 +137,24 @@ abstract class GoogleSignInPlatform extends PlatformInterface { /// Scopes should come from the full list /// [here](https://developers.google.com/identity/protocols/googlescopes). Future requestScopes(List scopes) async { - throw UnimplementedError('requestScopes() has not been implmented.'); + throw UnimplementedError('requestScopes() has not been implemented.'); } + + /// Determines if the current user can access all [scopes]. + /// + /// Optionally, an [accessToken] can be passed for applications where a + /// long-lived token may be cached (like the web). + Future canAccessScopes( + List scopes, { + String? accessToken, + }) async { + throw UnimplementedError('canAccessScopes() has not been implemented.'); + } + + /// Returns a stream of [GoogleSignInUserData] authentication events. + /// + /// These will normally come from asynchronous flows, like the Google Sign-In + /// Button Widget from the Web implementation, and will be funneled directly + /// to the `onCurrentUserChanged` Stream of the plugin. + Stream? get userDataEvents => null; } diff --git a/packages/google_sign_in/google_sign_in_platform_interface/pubspec.yaml b/packages/google_sign_in/google_sign_in_platform_interface/pubspec.yaml index 17645aa9ad40..8b9af5a424e1 100644 --- a/packages/google_sign_in/google_sign_in_platform_interface/pubspec.yaml +++ b/packages/google_sign_in/google_sign_in_platform_interface/pubspec.yaml @@ -4,7 +4,7 @@ repository: https://github.com/flutter/packages/tree/main/packages/google_sign_i issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+google_sign_in%22 # NOTE: We strongly prefer non-breaking changes, even at the expense of a # less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes -version: 2.3.1 +version: 2.4.0 environment: sdk: ">=2.18.0 <4.0.0" diff --git a/packages/google_sign_in/google_sign_in_platform_interface/test/method_channel_google_sign_in_test.dart b/packages/google_sign_in/google_sign_in_platform_interface/test/method_channel_google_sign_in_test.dart index 0837f6d5d02c..ac8b8ef20aab 100644 --- a/packages/google_sign_in/google_sign_in_platform_interface/test/method_channel_google_sign_in_test.dart +++ b/packages/google_sign_in/google_sign_in_platform_interface/test/method_channel_google_sign_in_test.dart @@ -141,6 +141,17 @@ void main() { expect(log, tests.values); }); + test('canAccessScopes is unimplemented', () async { + expect(() async { + await googleSignIn + .canAccessScopes(['someScope'], accessToken: 'token'); + }, throwsUnimplementedError); + }); + + test('userDataEvents returns null', () async { + expect(googleSignIn.userDataEvents, isNull); + }); + test('initWithParams passes through arguments to the channel', () async { await googleSignIn.initWithParams(const SignInInitParameters( hostedDomain: 'example.com',