[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.
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 e78060d..591f36e 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 8b755fb..c3b158d 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 @@
'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 e1f455d..422fe80 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 @@
this.signInOption = SignInOption.standard,
this.hostedDomain,
this.clientId,
+ this.serverClientId,
this.forceCodeForRefreshToken = false,
});
@@ -49,9 +50,30 @@
/// 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 9f6ab50..9ad3e1c 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 @@
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 1ffdc5a..944ad34 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 @@
'scopes': <String>['two', 'scopes'],
'signInOption': 'SignInOption.games',
'clientId': 'fakeClientId',
+ 'serverClientId': null,
'forceCodeForRefreshToken': false,
}),
() {
@@ -144,6 +145,7 @@
scopes: <String>['two', 'scopes'],
signInOption: SignInOption.games,
clientId: 'fakeClientId',
+ serverClientId: 'fakeServerClientId',
forceCodeForRefreshToken: true));
expect(log, <Matcher>[
isMethodCall('init', arguments: <String, dynamic>{
@@ -151,6 +153,7 @@
'scopes': <String>['two', 'scopes'],
'signInOption': 'SignInOption.games',
'clientId': 'fakeClientId',
+ 'serverClientId': 'fakeServerClientId',
'forceCodeForRefreshToken': true,
}),
]);