Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit 88dc5e3

Browse files
authored
[google_sign_in] Fix issue obtaining serverAuthCode on Android and add forceCodeForRefreshToken parameter (#3356)
1 parent 8a8e67a commit 88dc5e3

File tree

6 files changed

+26
-4
lines changed

6 files changed

+26
-4
lines changed

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,4 @@ Daniel Roek <[email protected]>
6868
TheOneWithTheBraid <[email protected]>
6969
Rulong Chen(陈汝龙) <[email protected]>
7070
Hwanseok Kang <[email protected]>
71+
Twin Sun, LLC <[email protected]>

packages/google_sign_in/google_sign_in/AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,4 @@ Aleksandr Yurkovskiy <[email protected]>
6464
Anton Borries <[email protected]>
6565
6666
Rahul Raj <[email protected]>
67+
Twin Sun, LLC <[email protected]>

packages/google_sign_in/google_sign_in/CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
## NEXT
1+
## 5.4.2
22

33
* Updates minimum Flutter version to 2.10.
4+
* Adds override for `GoogleSignInPlatform.initWithParams`.
5+
* Fixes tests to recognize new default `forceCodeForRefreshToken` request attribute.
46

57
## 5.4.1
68

packages/google_sign_in/google_sign_in/lib/google_sign_in.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,12 +179,16 @@ class GoogleSignIn {
179179
/// The [hostedDomain] argument specifies a hosted domain restriction. By
180180
/// setting this, sign in will be restricted to accounts of the user in the
181181
/// specified domain. By default, the list of accounts will not be restricted.
182+
///
183+
/// The [forceCodeForRefreshToken] is used on Android to ensure the authentication
184+
/// code can be exchanged for a refresh token after the first request.
182185
GoogleSignIn({
183186
this.signInOption = SignInOption.standard,
184187
this.scopes = const <String>[],
185188
this.hostedDomain,
186189
this.clientId,
187190
this.serverClientId,
191+
this.forceCodeForRefreshToken = false,
188192
});
189193

190194
/// Factory for creating default sign in user experience.
@@ -250,6 +254,9 @@ class GoogleSignIn {
250254
/// server.
251255
final String? serverClientId;
252256

257+
/// Force the authorization code to be valid for a refresh token every time. Only needed on Android.
258+
final bool forceCodeForRefreshToken;
259+
253260
final StreamController<GoogleSignInAccount?> _currentUserController =
254261
StreamController<GoogleSignInAccount?>.broadcast();
255262

@@ -286,6 +293,7 @@ class GoogleSignIn {
286293
hostedDomain: hostedDomain,
287294
clientId: clientId,
288295
serverClientId: serverClientId,
296+
forceCodeForRefreshToken: forceCodeForRefreshToken,
289297
))
290298
..catchError((dynamic _) {
291299
// Invalidate initialization if it errors out.

packages/google_sign_in/google_sign_in/pubspec.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: Flutter plugin for Google Sign-In, a secure authentication system
33
for signing in with a Google account on Android and iOS.
44
repository: https://github.com/flutter/plugins/tree/main/packages/google_sign_in/google_sign_in
55
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+google_sign_in%22
6-
version: 5.4.1
6+
version: 5.4.2
77

88

99
environment:
@@ -23,8 +23,8 @@ flutter:
2323
dependencies:
2424
flutter:
2525
sdk: flutter
26-
google_sign_in_android: ^6.0.0
27-
google_sign_in_ios: ^5.4.0
26+
google_sign_in_android: ^6.1.0
27+
google_sign_in_ios: ^5.5.0
2828
google_sign_in_platform_interface: ^2.2.0
2929
google_sign_in_web: ^0.10.0
3030

packages/google_sign_in/google_sign_in/test/google_sign_in_test.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,16 @@ void main() {
8080
verify(mockPlatform.signIn());
8181
});
8282

83+
test('forceCodeForRefreshToken sent with init method call', () async {
84+
final GoogleSignIn googleSignIn =
85+
GoogleSignIn(forceCodeForRefreshToken: true);
86+
87+
await googleSignIn.signIn();
88+
89+
_verifyInit(mockPlatform, forceCodeForRefreshToken: true);
90+
verify(mockPlatform.signIn());
91+
});
92+
8393
test('signOut', () async {
8494
final GoogleSignIn googleSignIn = GoogleSignIn();
8595

0 commit comments

Comments
 (0)