Skip to content

Commit 6f6b356

Browse files
blaugoldmauricioluz
authored andcommitted
[google_sign_in_platform_interface] Add support for serverClientId (flutter#5256)
This PR is a prerequisite for implementing flutter#5250. It adds support for passing a server client ID to platform implementations when initializing them.
1 parent 1a5996d commit 6f6b356

File tree

5 files changed

+32
-2
lines changed

5 files changed

+32
-2
lines changed

packages/google_sign_in/google_sign_in_platform_interface/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2.2.0
2+
3+
* Adds support for the `serverClientId` parameter.
4+
15
## 2.1.3
26

37
* Enables mocking models by changing overridden operator == parameter type from `dynamic` to `Object`.

packages/google_sign_in/google_sign_in_platform_interface/lib/src/method_channel_google_sign_in.dart

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class MethodChannelGoogleSignIn extends GoogleSignInPlatform {
3939
'scopes': params.scopes,
4040
'hostedDomain': params.hostedDomain,
4141
'clientId': params.clientId,
42+
'serverClientId': params.serverClientId,
4243
'forceCodeForRefreshToken': params.forceCodeForRefreshToken,
4344
});
4445
}

packages/google_sign_in/google_sign_in_platform_interface/lib/src/types.dart

+23-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class SignInInitParameters {
3535
this.signInOption = SignInOption.standard,
3636
this.hostedDomain,
3737
this.clientId,
38+
this.serverClientId,
3839
this.forceCodeForRefreshToken = false,
3940
});
4041

@@ -49,9 +50,30 @@ class SignInInitParameters {
4950
/// By default, the list of accounts will not be restricted.
5051
final String? hostedDomain;
5152

52-
/// The client ID to use when signing in.
53+
/// The OAuth client ID of the app.
54+
///
55+
/// The default is null, which means that the client ID will be sourced from a
56+
/// configuration file, if required on the current platform. A value specified
57+
/// here takes precedence over a value specified in a configuration file.
58+
/// See also:
59+
///
60+
/// * [Platform Integration](https://github.com/flutter/plugins/tree/main/packages/google_sign_in/google_sign_in#platform-integration),
61+
/// where you can find the details about the configuration files.
5362
final String? clientId;
5463

64+
/// The OAuth client ID of the backend server.
65+
///
66+
/// The default is null, which means that the server client ID will be sourced
67+
/// from a configuration file, if available and supported on the current
68+
/// platform. A value specified here takes precedence over a value specified
69+
/// in a configuration file.
70+
///
71+
/// See also:
72+
///
73+
/// * [Platform Integration](https://github.com/flutter/plugins/tree/main/packages/google_sign_in/google_sign_in#platform-integration),
74+
/// where you can find the details about the configuration files.
75+
final String? serverClientId;
76+
5577
/// If true, ensures the authorization code can be exchanged for an access
5678
/// token.
5779
///

packages/google_sign_in/google_sign_in_platform_interface/pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ repository: https://github.com/flutter/plugins/tree/main/packages/google_sign_in
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+google_sign_in%22
55
# NOTE: We strongly prefer non-breaking changes, even at the expense of a
66
# less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes
7-
version: 2.1.3
7+
version: 2.2.0
88

99
environment:
1010
sdk: ">=2.12.0 <3.0.0"

packages/google_sign_in/google_sign_in_platform_interface/test/method_channel_google_sign_in_test.dart

+3
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ void main() {
107107
'scopes': <String>['two', 'scopes'],
108108
'signInOption': 'SignInOption.games',
109109
'clientId': 'fakeClientId',
110+
'serverClientId': null,
110111
'forceCodeForRefreshToken': false,
111112
}),
112113
() {
@@ -144,13 +145,15 @@ void main() {
144145
scopes: <String>['two', 'scopes'],
145146
signInOption: SignInOption.games,
146147
clientId: 'fakeClientId',
148+
serverClientId: 'fakeServerClientId',
147149
forceCodeForRefreshToken: true));
148150
expect(log, <Matcher>[
149151
isMethodCall('init', arguments: <String, dynamic>{
150152
'hostedDomain': 'example.com',
151153
'scopes': <String>['two', 'scopes'],
152154
'signInOption': 'SignInOption.games',
153155
'clientId': 'fakeClientId',
156+
'serverClientId': 'fakeServerClientId',
154157
'forceCodeForRefreshToken': true,
155158
}),
156159
]);

0 commit comments

Comments
 (0)