[google_sign_in] Add new Oauth scope methods to google_sign_in_platform_interface. (#2547)
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 7819e74..c0627df 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,3 +1,8 @@ +## 1.1.0 + +* Add hasRequestedScope method to determine if an Oauth scope has been granted. +* Add requestScope Method to request new Oauth scopes be granted by the user. + ## 1.0.4 * Make the pedantic dev_dependency explicit.
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 0123015..966e935 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
@@ -121,4 +121,12 @@ Future<void> clearAuthCache({@required String token}) async { throw UnimplementedError('clearAuthCache() has not been implemented.'); } + + /// Requests the user grants additional Oauth [scopes]. + /// + /// Scopes should come from the full list + /// [here](https://developers.google.com/identity/protocols/googlescopes). + Future<bool> requestScopes(List<String> scopes) async { + throw UnimplementedError('requestScopes() has not been implmented.'); + } }
diff --git a/packages/google_sign_in/google_sign_in_platform_interface/lib/src/method_channel_google_sign_in.dart b/packages/google_sign_in/google_sign_in_platform_interface/lib/src/method_channel_google_sign_in.dart index 1d1eb64..4d2a34f 100644 --- a/packages/google_sign_in/google_sign_in_platform_interface/lib/src/method_channel_google_sign_in.dart +++ b/packages/google_sign_in/google_sign_in_platform_interface/lib/src/method_channel_google_sign_in.dart
@@ -78,4 +78,12 @@ <String, String>{'token': token}, ); } + + @override + Future<bool> requestScopes(List<String> scopes) { + return channel.invokeMethod<bool>( + 'requestScopes', + <String, List<String>>{'scopes': scopes}, + ); + } }
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 23937e2..d1f7abc 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
@@ -3,7 +3,7 @@ homepage: https://github.com/flutter/plugins/tree/master/packages/google_sign_in/google_sign_in_platform_interface # 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: 1.0.4 +version: 1.1.0 dependencies: flutter:
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 13de6ac..6a8f7373 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
@@ -114,6 +114,11 @@ }: isMethodCall('clearAuthCache', arguments: <String, dynamic>{ 'token': 'abc', }), + () { + googleSignIn.requestScopes(['newScope', 'anotherScope']); + }: isMethodCall('requestScopes', arguments: <String, dynamic>{ + 'scopes': ['newScope', 'anotherScope'], + }), googleSignIn.signOut: isMethodCall('signOut', arguments: null), googleSignIn.disconnect: isMethodCall('disconnect', arguments: null), googleSignIn.isSignedIn: isMethodCall('isSignedIn', arguments: null),