[google_sign_in] Fix issue obtaining serverAuthCode on Android and add forceCodeForRefreshToken parameter (#3356)

diff --git a/AUTHORS b/AUTHORS
index 31402c7..3112c3b 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -68,3 +68,4 @@
 TheOneWithTheBraid <the-one@with-the-braid.cf>
 Rulong Chen(陈汝龙) <rulong.crl@alibaba-inc.com>
 Hwanseok Kang <tttkhs96@gmail.com>
+Twin Sun, LLC <google-contrib@twinsunsolutions.com>
diff --git a/packages/google_sign_in/google_sign_in/AUTHORS b/packages/google_sign_in/google_sign_in/AUTHORS
index 493a0b4..35d24a5 100644
--- a/packages/google_sign_in/google_sign_in/AUTHORS
+++ b/packages/google_sign_in/google_sign_in/AUTHORS
@@ -64,3 +64,4 @@
 Anton Borries <mail@antonborri.es>
 Alex Li <google@alexv525.com>
 Rahul Raj <64.rahulraj@gmail.com>
+Twin Sun, LLC <google-contrib@twinsunsolutions.com>
diff --git a/packages/google_sign_in/google_sign_in/CHANGELOG.md b/packages/google_sign_in/google_sign_in/CHANGELOG.md
index 286365e..9349784 100644
--- a/packages/google_sign_in/google_sign_in/CHANGELOG.md
+++ b/packages/google_sign_in/google_sign_in/CHANGELOG.md
@@ -1,6 +1,8 @@
-## NEXT
+## 5.4.2
 
 * Updates minimum Flutter version to 2.10.
+* Adds override for `GoogleSignInPlatform.initWithParams`.
+* Fixes tests to recognize new default `forceCodeForRefreshToken` request attribute.
 
 ## 5.4.1
 
diff --git a/packages/google_sign_in/google_sign_in/lib/google_sign_in.dart b/packages/google_sign_in/google_sign_in/lib/google_sign_in.dart
index 135c422..3ae0223 100644
--- a/packages/google_sign_in/google_sign_in/lib/google_sign_in.dart
+++ b/packages/google_sign_in/google_sign_in/lib/google_sign_in.dart
@@ -179,12 +179,16 @@
   /// The [hostedDomain] argument specifies a hosted domain restriction. By
   /// setting this, sign in will be restricted to accounts of the user in the
   /// specified domain. By default, the list of accounts will not be restricted.
+  ///
+  /// The [forceCodeForRefreshToken] is used on Android to ensure the authentication
+  /// code can be exchanged for a refresh token after the first request.
   GoogleSignIn({
     this.signInOption = SignInOption.standard,
     this.scopes = const <String>[],
     this.hostedDomain,
     this.clientId,
     this.serverClientId,
+    this.forceCodeForRefreshToken = false,
   });
 
   /// Factory for creating default sign in user experience.
@@ -250,6 +254,9 @@
   /// server.
   final String? serverClientId;
 
+  /// Force the authorization code to be valid for a refresh token every time. Only needed on Android.
+  final bool forceCodeForRefreshToken;
+
   final StreamController<GoogleSignInAccount?> _currentUserController =
       StreamController<GoogleSignInAccount?>.broadcast();
 
@@ -286,6 +293,7 @@
       hostedDomain: hostedDomain,
       clientId: clientId,
       serverClientId: serverClientId,
+      forceCodeForRefreshToken: forceCodeForRefreshToken,
     ))
           ..catchError((dynamic _) {
             // Invalidate initialization if it errors out.
diff --git a/packages/google_sign_in/google_sign_in/pubspec.yaml b/packages/google_sign_in/google_sign_in/pubspec.yaml
index 5033990..c32dee7 100644
--- a/packages/google_sign_in/google_sign_in/pubspec.yaml
+++ b/packages/google_sign_in/google_sign_in/pubspec.yaml
@@ -3,7 +3,7 @@
   for signing in with a Google account on Android and iOS.
 repository: https://github.com/flutter/plugins/tree/main/packages/google_sign_in/google_sign_in
 issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+google_sign_in%22
-version: 5.4.1
+version: 5.4.2
 
 
 environment:
@@ -23,8 +23,8 @@
 dependencies:
   flutter:
     sdk: flutter
-  google_sign_in_android: ^6.0.0
-  google_sign_in_ios: ^5.4.0
+  google_sign_in_android: ^6.1.0
+  google_sign_in_ios: ^5.5.0
   google_sign_in_platform_interface: ^2.2.0
   google_sign_in_web: ^0.10.0
 
diff --git a/packages/google_sign_in/google_sign_in/test/google_sign_in_test.dart b/packages/google_sign_in/google_sign_in/test/google_sign_in_test.dart
index b8676bd..b8a596b 100644
--- a/packages/google_sign_in/google_sign_in/test/google_sign_in_test.dart
+++ b/packages/google_sign_in/google_sign_in/test/google_sign_in_test.dart
@@ -80,6 +80,16 @@
       verify(mockPlatform.signIn());
     });
 
+    test('forceCodeForRefreshToken sent with init method call', () async {
+      final GoogleSignIn googleSignIn =
+          GoogleSignIn(forceCodeForRefreshToken: true);
+
+      await googleSignIn.signIn();
+
+      _verifyInit(mockPlatform, forceCodeForRefreshToken: true);
+      verify(mockPlatform.signIn());
+    });
+
     test('signOut', () async {
       final GoogleSignIn googleSignIn = GoogleSignIn();