From 0633bfbe2ab3f0b4a61c6f568657a4d85f99a731 Mon Sep 17 00:00:00 2001 From: Gabriel Terwesten Date: Thu, 23 Jun 2022 16:00:54 +0200 Subject: [PATCH] [google_sign_in_platform_interface] Add support for `serverClientId` (#5256) This PR is a prerequisite for implementing #5250. It adds support for passing a server client ID to platform implementations when initializing them. --- .../CHANGELOG.md | 4 ++++ .../src/method_channel_google_sign_in.dart | 1 + .../lib/src/types.dart | 24 ++++++++++++++++++- .../pubspec.yaml | 2 +- .../method_channel_google_sign_in_test.dart | 3 +++ 5 files changed, 32 insertions(+), 2 deletions(-) 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 e78060d84744..591f36eb1ae8 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,7 @@ +## 2.2.0 + +* Adds support for the `serverClientId` parameter. + ## 2.1.3 * Enables mocking models by changing overridden operator == parameter type from `dynamic` to `Object`. 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 8b755fbf1cdd..c3b158dd8450 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 @@ -39,6 +39,7 @@ class MethodChannelGoogleSignIn extends GoogleSignInPlatform { 'scopes': params.scopes, 'hostedDomain': params.hostedDomain, 'clientId': params.clientId, + 'serverClientId': params.serverClientId, 'forceCodeForRefreshToken': params.forceCodeForRefreshToken, }); } diff --git a/packages/google_sign_in/google_sign_in_platform_interface/lib/src/types.dart b/packages/google_sign_in/google_sign_in_platform_interface/lib/src/types.dart index e1f455d6ea44..422fe807253d 100644 --- a/packages/google_sign_in/google_sign_in_platform_interface/lib/src/types.dart +++ b/packages/google_sign_in/google_sign_in_platform_interface/lib/src/types.dart @@ -35,6 +35,7 @@ class SignInInitParameters { this.signInOption = SignInOption.standard, this.hostedDomain, this.clientId, + this.serverClientId, this.forceCodeForRefreshToken = false, }); @@ -49,9 +50,30 @@ class SignInInitParameters { /// By default, the list of accounts will not be restricted. final String? hostedDomain; - /// The client ID to use when signing in. + /// The OAuth client ID of the app. + /// + /// The default is null, which means that the client ID will be sourced from a + /// configuration file, if required on the current platform. A value specified + /// here takes precedence over a value specified in a configuration file. + /// See also: + /// + /// * [Platform Integration](https://github.com/flutter/plugins/tree/main/packages/google_sign_in/google_sign_in#platform-integration), + /// where you can find the details about the configuration files. final String? clientId; + /// The OAuth client ID of the backend server. + /// + /// The default is null, which means that the server client ID will be sourced + /// from a configuration file, if available and supported on the current + /// platform. A value specified here takes precedence over a value specified + /// in a configuration file. + /// + /// See also: + /// + /// * [Platform Integration](https://github.com/flutter/plugins/tree/main/packages/google_sign_in/google_sign_in#platform-integration), + /// where you can find the details about the configuration files. + final String? serverClientId; + /// If true, ensures the authorization code can be exchanged for an access /// token. /// 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 9f6ab508d249..9ad3e1cf005b 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/plugins/tree/main/packages/google_sign_in 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.1.3 +version: 2.2.0 environment: sdk: ">=2.12.0 <3.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 1ffdc5a4f95e..944ad3419b8e 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 @@ -107,6 +107,7 @@ void main() { 'scopes': ['two', 'scopes'], 'signInOption': 'SignInOption.games', 'clientId': 'fakeClientId', + 'serverClientId': null, 'forceCodeForRefreshToken': false, }), () { @@ -144,6 +145,7 @@ void main() { scopes: ['two', 'scopes'], signInOption: SignInOption.games, clientId: 'fakeClientId', + serverClientId: 'fakeServerClientId', forceCodeForRefreshToken: true)); expect(log, [ isMethodCall('init', arguments: { @@ -151,6 +153,7 @@ void main() { 'scopes': ['two', 'scopes'], 'signInOption': 'SignInOption.games', 'clientId': 'fakeClientId', + 'serverClientId': 'fakeServerClientId', 'forceCodeForRefreshToken': true, }), ]);