From b072fa1336533b6954b209fa3afe60a67bdaf3d0 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Mon, 18 Aug 2025 12:39:59 +0000 Subject: [PATCH 01/18] feat(google_sign_in): add clearAuthCache API Adds a new `clearAuthCache` method to the `google_sign_in` plugin. This method allows developers to clear the auth cache for a signed-in user. The implementation is provided for the Android and Web platforms. On Android, it calls `AuthorizationClient.clearToken`. On Web, it removes the matching entry from an in-memory cache. --- .../example/pubspec.yaml | 4 +++ .../pubspec.yaml | 4 +++ .../google_sign_in/CHANGELOG.md | 3 +- .../google_sign_in/example/pubspec.yaml | 4 +++ .../google_sign_in/lib/google_sign_in.dart | 13 +++++++++ .../google_sign_in/pubspec.yaml | 14 ++++++---- .../test/google_sign_in_test.mocks.dart | 27 ++++++++++++------ .../google_sign_in_android/CHANGELOG.md | 3 +- .../googlesignin/GoogleSignInPlugin.java | 17 +++++++++++ .../flutter/plugins/googlesignin/Messages.kt | 25 +++++++++++++++++ .../googlesignin/GoogleSignInTest.java | 17 +++++++++++ .../example/pubspec.yaml | 4 +++ .../lib/google_sign_in_android.dart | 5 ++++ .../lib/src/messages.g.dart | 28 +++++++++++++++++++ .../pigeons/messages.dart | 4 +++ .../google_sign_in_android/pubspec.yaml | 5 ++-- .../google_sign_in_android_test.mocks.dart | 9 ++++++ .../google_sign_in_ios/example/pubspec.yaml | 4 +++ .../google_sign_in_ios/pubspec.yaml | 3 +- .../CHANGELOG.md | 3 +- .../google_sign_in_platform_interface.dart | 12 ++++++++ .../pubspec.yaml | 2 +- .../google_sign_in_web/CHANGELOG.md | 3 +- .../google_sign_in_web_test.dart | 16 +++++++++++ .../google_sign_in_web/example/pubspec.yaml | 4 +++ .../lib/google_sign_in_web.dart | 6 ++++ .../lib/src/gis_client.dart | 8 ++++++ .../google_sign_in_web/pubspec.yaml | 5 ++-- script/tool/bin/flutter_plugin_tools.dart | 0 29 files changed, 228 insertions(+), 24 deletions(-) mode change 100644 => 100755 script/tool/bin/flutter_plugin_tools.dart diff --git a/packages/extension_google_sign_in_as_googleapis_auth/example/pubspec.yaml b/packages/extension_google_sign_in_as_googleapis_auth/example/pubspec.yaml index 8a297916798..7c4c667f1d8 100644 --- a/packages/extension_google_sign_in_as_googleapis_auth/example/pubspec.yaml +++ b/packages/extension_google_sign_in_as_googleapis_auth/example/pubspec.yaml @@ -26,3 +26,7 @@ dev_dependencies: flutter: uses-material-design: true +# FOR TESTING AND INITIAL REVIEW ONLY. DO NOT MERGE. +# See https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins +dependency_overrides: + google_sign_in: {path: ../../../packages/google_sign_in/google_sign_in} diff --git a/packages/extension_google_sign_in_as_googleapis_auth/pubspec.yaml b/packages/extension_google_sign_in_as_googleapis_auth/pubspec.yaml index c36b2a630e2..eef00e770d2 100644 --- a/packages/extension_google_sign_in_as_googleapis_auth/pubspec.yaml +++ b/packages/extension_google_sign_in_as_googleapis_auth/pubspec.yaml @@ -32,3 +32,7 @@ topics: false_secrets: - example/android/app/google-services.json +# FOR TESTING AND INITIAL REVIEW ONLY. DO NOT MERGE. +# See https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins +dependency_overrides: + google_sign_in: {path: ../../packages/google_sign_in/google_sign_in} diff --git a/packages/google_sign_in/google_sign_in/CHANGELOG.md b/packages/google_sign_in/google_sign_in/CHANGELOG.md index 9ae572566f0..4b65fced4ed 100644 --- a/packages/google_sign_in/google_sign_in/CHANGELOG.md +++ b/packages/google_sign_in/google_sign_in/CHANGELOG.md @@ -1,5 +1,6 @@ -## NEXT +## 7.1.2 +* feat(google_sign_in): Add `clearAuthCache` method to remove an access token from the cache. * Updates minimum supported SDK version to Flutter 3.29/Dart 3.7. ## 7.1.1 diff --git a/packages/google_sign_in/google_sign_in/example/pubspec.yaml b/packages/google_sign_in/google_sign_in/example/pubspec.yaml index ee2e2e1d4be..3b9e6f214cc 100644 --- a/packages/google_sign_in/google_sign_in/example/pubspec.yaml +++ b/packages/google_sign_in/google_sign_in/example/pubspec.yaml @@ -28,3 +28,7 @@ dev_dependencies: flutter: uses-material-design: true +# FOR TESTING AND INITIAL REVIEW ONLY. DO NOT MERGE. +# See https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins +dependency_overrides: + google_sign_in_web: {path: ../../../../packages/google_sign_in/google_sign_in_web} 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 9d8caafd0ec..6dca4fb4be9 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 @@ -575,4 +575,17 @@ class GoogleSignIn { // single user at a time, so the distinction is mostly theoretical for now. await GoogleSignInPlatform.instance.disconnect(const DisconnectParams()); } + + /// Clears the authentication cache of the specified token. + /// + /// How this method works depends on the platform: + /// + /// - On Android, this will attempt to clear the token from the cache. + /// - On Web, this will remove any matching entry from the token cache. + /// + /// This should be called on any client that has received an access token that + /// is no longer valid. + Future clearAuthCache({required String token}) { + return GoogleSignInPlatform.instance.clearAuthCache(token: token); + } } diff --git a/packages/google_sign_in/google_sign_in/pubspec.yaml b/packages/google_sign_in/google_sign_in/pubspec.yaml index 3e2a6f7afa2..49a64343612 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 @@ description: Flutter plugin for Google Sign-In, a secure authentication system for signing in with a Google account. repository: https://github.com/flutter/packages/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: 7.1.1 +version: 7.1.2 environment: sdk: ^3.7.0 @@ -24,10 +24,14 @@ flutter: dependencies: flutter: sdk: flutter - google_sign_in_android: ^7.0.0 - google_sign_in_ios: ^6.0.0 - google_sign_in_platform_interface: ^3.0.0 - google_sign_in_web: ^1.0.0 + google_sign_in_android: + path: ../google_sign_in_android + google_sign_in_ios: + path: ../google_sign_in_ios + google_sign_in_platform_interface: + path: ../google_sign_in_platform_interface + google_sign_in_web: + path: ../google_sign_in_web dev_dependencies: build_runner: ^2.1.10 diff --git a/packages/google_sign_in/google_sign_in/test/google_sign_in_test.mocks.dart b/packages/google_sign_in/google_sign_in/test/google_sign_in_test.mocks.dart index f7db7677e2a..e1678bfa772 100644 --- a/packages/google_sign_in/google_sign_in/test/google_sign_in_test.mocks.dart +++ b/packages/google_sign_in/google_sign_in/test/google_sign_in_test.mocks.dart @@ -1,4 +1,4 @@ -// Mocks generated by Mockito 5.4.5 from annotations +// Mocks generated by Mockito 5.4.6 from annotations // in google_sign_in/test/google_sign_in_test.dart. // Do not manually edit this file. @@ -57,6 +57,14 @@ class MockGoogleSignInPlatform extends _i1.Mock ) as _i4.Future<_i2.AuthenticationResults?>?); + @override + bool supportsAuthenticate() => + (super.noSuchMethod( + Invocation.method(#supportsAuthenticate, []), + returnValue: false, + ) + as bool); + @override _i4.Future<_i2.AuthenticationResults> authenticate( _i2.AuthenticateParameters? params, @@ -72,14 +80,6 @@ class MockGoogleSignInPlatform extends _i1.Mock ) as _i4.Future<_i2.AuthenticationResults>); - @override - bool supportsAuthenticate() => - (super.noSuchMethod( - Invocation.method(#supportsAuthenticate, []), - returnValue: false, - ) - as bool); - @override bool authorizationRequiresUserInteraction() => (super.noSuchMethod( @@ -127,4 +127,13 @@ class MockGoogleSignInPlatform extends _i1.Mock returnValueForMissingStub: _i4.Future.value(), ) as _i4.Future); + + @override + _i4.Future clearAuthCache({required String? token}) => + (super.noSuchMethod( + Invocation.method(#clearAuthCache, [], {#token: token}), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) + as _i4.Future); } diff --git a/packages/google_sign_in/google_sign_in_android/CHANGELOG.md b/packages/google_sign_in/google_sign_in_android/CHANGELOG.md index 4602374999c..783a3dd15f2 100644 --- a/packages/google_sign_in/google_sign_in_android/CHANGELOG.md +++ b/packages/google_sign_in/google_sign_in_android/CHANGELOG.md @@ -1,5 +1,6 @@ -## NEXT +## 7.0.4 +* feat(google_sign_in): Add `clearAuthCache` method to remove an access token from the cache. * Updates minimum supported SDK version to Flutter 3.29/Dart 3.7. ## 7.0.3 diff --git a/packages/google_sign_in/google_sign_in_android/android/src/main/java/io/flutter/plugins/googlesignin/GoogleSignInPlugin.java b/packages/google_sign_in/google_sign_in_android/android/src/main/java/io/flutter/plugins/googlesignin/GoogleSignInPlugin.java index 5ff805d1308..c9aa89ad4d1 100644 --- a/packages/google_sign_in/google_sign_in_android/android/src/main/java/io/flutter/plugins/googlesignin/GoogleSignInPlugin.java +++ b/packages/google_sign_in/google_sign_in_android/android/src/main/java/io/flutter/plugins/googlesignin/GoogleSignInPlugin.java @@ -342,6 +342,23 @@ public void onError(@NonNull ClearCredentialException e) { }); } + @Override + public void clearAuthCache( + @NonNull String token, @NonNull Function1, Unit> callback) { + authorizationClientFactory + .create(context) + .clearToken(token) + .addOnSuccessListener( + (Void) -> { + ResultUtilsKt.completeWithUnitSuccess(callback); + }) + .addOnFailureListener( + (Exception e) -> { + ResultUtilsKt.completeWithFlutterError( + callback, new FlutterError("clearAuthCacheFailed", e.getMessage(), null)); + }); + } + @Override public void authorize( @NonNull PlatformAuthorizationRequest params, diff --git a/packages/google_sign_in/google_sign_in_android/android/src/main/kotlin/io/flutter/plugins/googlesignin/Messages.kt b/packages/google_sign_in/google_sign_in_android/android/src/main/kotlin/io/flutter/plugins/googlesignin/Messages.kt index db70b631916..9b6402e00c4 100644 --- a/packages/google_sign_in/google_sign_in_android/android/src/main/kotlin/io/flutter/plugins/googlesignin/Messages.kt +++ b/packages/google_sign_in/google_sign_in_android/android/src/main/kotlin/io/flutter/plugins/googlesignin/Messages.kt @@ -477,6 +477,8 @@ interface GoogleSignInApi { ) /** Clears CredentialManager credential state. */ fun clearCredentialState(callback: (Result) -> Unit) + /** Clears the authorization cache for the given token. */ + fun clearAuthCache(token: String, callback: (Result) -> Unit) /** Requests authorization tokens via AuthorizationClient. */ fun authorize( params: PlatformAuthorizationRequest, @@ -563,6 +565,29 @@ interface GoogleSignInApi { channel.setMessageHandler(null) } } + run { + val channel = + BasicMessageChannel( + binaryMessenger, + "dev.flutter.pigeon.google_sign_in_android.GoogleSignInApi.clearAuthCache$separatedMessageChannelSuffix", + codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val tokenArg = args[0] as String + api.clearAuthCache(tokenArg) { result: Result -> + val error = result.exceptionOrNull() + if (error != null) { + reply.reply(wrapError(error)) + } else { + reply.reply(wrapResult(null)) + } + } + } + } else { + channel.setMessageHandler(null) + } + } run { val channel = BasicMessageChannel( diff --git a/packages/google_sign_in/google_sign_in_android/android/src/test/java/io/flutter/plugins/googlesignin/GoogleSignInTest.java b/packages/google_sign_in/google_sign_in_android/android/src/test/java/io/flutter/plugins/googlesignin/GoogleSignInTest.java index ae3a05d83cb..31c59c27eaa 100644 --- a/packages/google_sign_in/google_sign_in_android/android/src/test/java/io/flutter/plugins/googlesignin/GoogleSignInTest.java +++ b/packages/google_sign_in/google_sign_in_android/android/src/test/java/io/flutter/plugins/googlesignin/GoogleSignInTest.java @@ -1097,4 +1097,21 @@ public void clearCredentialState_reportsFailure() { callbackCaptor.getValue().onError(mock(ClearCredentialException.class)); } + + @Test + public void clearAuthCache_callsClient() { + final Task mockTask = mock(Task.class); + when(mockAuthorizationClient.clearToken(any())).thenReturn(mockTask); + plugin.clearAuthCache( + "test_token", + ResultCompat.asCompatCallback( + reply -> { + // This test doesn't trigger the getCredentialsAsync callback that would call this, + // so if this is reached something has gone wrong. + fail(); + return null; + })); + + verify(mockAuthorizationClient).clearToken("test_token"); + } } diff --git a/packages/google_sign_in/google_sign_in_android/example/pubspec.yaml b/packages/google_sign_in/google_sign_in_android/example/pubspec.yaml index 4fd0ceafa5e..aa304309af3 100644 --- a/packages/google_sign_in/google_sign_in_android/example/pubspec.yaml +++ b/packages/google_sign_in/google_sign_in_android/example/pubspec.yaml @@ -28,3 +28,7 @@ dev_dependencies: flutter: uses-material-design: true +# FOR TESTING AND INITIAL REVIEW ONLY. DO NOT MERGE. +# See https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins +dependency_overrides: + google_sign_in_platform_interface: {path: ../../../../packages/google_sign_in/google_sign_in_platform_interface} diff --git a/packages/google_sign_in/google_sign_in_android/lib/google_sign_in_android.dart b/packages/google_sign_in/google_sign_in_android/lib/google_sign_in_android.dart index efe5e8df4cd..e7918d9292f 100644 --- a/packages/google_sign_in/google_sign_in_android/lib/google_sign_in_android.dart +++ b/packages/google_sign_in/google_sign_in_android/lib/google_sign_in_android.dart @@ -27,6 +27,11 @@ class GoogleSignInAndroid extends GoogleSignInPlatform { GoogleSignInPlatform.instance = GoogleSignInAndroid(); } + @override + Future clearAuthCache({required String token}) { + return _hostApi.clearAuthCache(token); + } + @override Future init(InitParameters params) async { _hostedDomain = params.hostedDomain; diff --git a/packages/google_sign_in/google_sign_in_android/lib/src/messages.g.dart b/packages/google_sign_in/google_sign_in_android/lib/src/messages.g.dart index b46f99ff9e0..9330273acfe 100644 --- a/packages/google_sign_in/google_sign_in_android/lib/src/messages.g.dart +++ b/packages/google_sign_in/google_sign_in_android/lib/src/messages.g.dart @@ -525,6 +525,34 @@ class GoogleSignInApi { } } + /// Clears the authorization cache for the given token. + Future clearAuthCache(String token) async { + final String pigeonVar_channelName = + 'dev.flutter.pigeon.google_sign_in_android.GoogleSignInApi.clearAuthCache$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = + BasicMessageChannel( + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final Future pigeonVar_sendFuture = pigeonVar_channel.send( + [token], + ); + final List? pigeonVar_replyList = + await pigeonVar_sendFuture as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { + throw PlatformException( + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], + ); + } else { + return; + } + } + /// Requests authorization tokens via AuthorizationClient. Future authorize( PlatformAuthorizationRequest params, { diff --git a/packages/google_sign_in/google_sign_in_android/pigeons/messages.dart b/packages/google_sign_in/google_sign_in_android/pigeons/messages.dart index 59da01fd955..bbc47d1a711 100644 --- a/packages/google_sign_in/google_sign_in_android/pigeons/messages.dart +++ b/packages/google_sign_in/google_sign_in_android/pigeons/messages.dart @@ -194,6 +194,10 @@ abstract class GoogleSignInApi { @async void clearCredentialState(); + /// Clears the authorization cache for the given token. + @async + void clearAuthCache(String token); + /// Requests authorization tokens via AuthorizationClient. @async AuthorizeResult authorize( diff --git a/packages/google_sign_in/google_sign_in_android/pubspec.yaml b/packages/google_sign_in/google_sign_in_android/pubspec.yaml index 1bb236a7a10..02d40e17ca1 100644 --- a/packages/google_sign_in/google_sign_in_android/pubspec.yaml +++ b/packages/google_sign_in/google_sign_in_android/pubspec.yaml @@ -2,7 +2,7 @@ name: google_sign_in_android description: Android implementation of the google_sign_in plugin. repository: https://github.com/flutter/packages/tree/main/packages/google_sign_in/google_sign_in_android issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+google_sign_in%22 -version: 7.0.3 +version: 7.0.4 environment: sdk: ^3.7.0 @@ -20,7 +20,8 @@ flutter: dependencies: flutter: sdk: flutter - google_sign_in_platform_interface: ^3.0.0 + google_sign_in_platform_interface: + path: ../google_sign_in_platform_interface dev_dependencies: build_runner: ^2.3.0 diff --git a/packages/google_sign_in/google_sign_in_android/test/google_sign_in_android_test.mocks.dart b/packages/google_sign_in/google_sign_in_android/test/google_sign_in_android_test.mocks.dart index f3327d75516..618bad201a1 100644 --- a/packages/google_sign_in/google_sign_in_android/test/google_sign_in_android_test.mocks.dart +++ b/packages/google_sign_in/google_sign_in_android/test/google_sign_in_android_test.mocks.dart @@ -82,6 +82,15 @@ class MockGoogleSignInApi extends _i1.Mock implements _i2.GoogleSignInApi { ) as _i4.Future); + @override + _i4.Future clearAuthCache(String? token) => + (super.noSuchMethod( + Invocation.method(#clearAuthCache, [token]), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) + as _i4.Future); + @override _i4.Future<_i2.AuthorizeResult> authorize( _i2.PlatformAuthorizationRequest? params, { diff --git a/packages/google_sign_in/google_sign_in_ios/example/pubspec.yaml b/packages/google_sign_in/google_sign_in_ios/example/pubspec.yaml index bc12daff1c2..1ab1feeea15 100644 --- a/packages/google_sign_in/google_sign_in_ios/example/pubspec.yaml +++ b/packages/google_sign_in/google_sign_in_ios/example/pubspec.yaml @@ -27,3 +27,7 @@ dev_dependencies: flutter: uses-material-design: true +# FOR TESTING AND INITIAL REVIEW ONLY. DO NOT MERGE. +# See https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins +dependency_overrides: + google_sign_in_platform_interface: {path: ../../../../packages/google_sign_in/google_sign_in_platform_interface} diff --git a/packages/google_sign_in/google_sign_in_ios/pubspec.yaml b/packages/google_sign_in/google_sign_in_ios/pubspec.yaml index eb0b202314f..6df1b4272a9 100644 --- a/packages/google_sign_in/google_sign_in_ios/pubspec.yaml +++ b/packages/google_sign_in/google_sign_in_ios/pubspec.yaml @@ -24,7 +24,8 @@ flutter: dependencies: flutter: sdk: flutter - google_sign_in_platform_interface: ^3.0.0 + google_sign_in_platform_interface: + path: ../google_sign_in_platform_interface dev_dependencies: build_runner: ^2.4.6 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 b970b7c1095..ce1bd804252 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,5 +1,6 @@ -## NEXT +## 3.0.1 +* feat(google_sign_in): Add `clearAuthCache` method to remove an access token from the cache. * Updates minimum supported SDK version to Flutter 3.29/Dart 3.7. ## 3.0.0 diff --git a/packages/google_sign_in/google_sign_in_platform_interface/lib/google_sign_in_platform_interface.dart b/packages/google_sign_in/google_sign_in_platform_interface/lib/google_sign_in_platform_interface.dart index bfcc4ab6e74..4adf2d96f1a 100644 --- a/packages/google_sign_in/google_sign_in_platform_interface/lib/google_sign_in_platform_interface.dart +++ b/packages/google_sign_in/google_sign_in_platform_interface/lib/google_sign_in_platform_interface.dart @@ -105,6 +105,13 @@ abstract class GoogleSignInPlatform extends PlatformInterface { /// them out. Future disconnect(DisconnectParams params); + /// Clears the token cache for the given `token`. + /// + /// How this is implemented is up to the platform. + Future clearAuthCache({required String token}) { + throw UnimplementedError('clearAuthCache() has not been implemented.'); + } + /// Returns a stream of authentication events. /// /// If this is not overridden, the app-facing package will assume that the @@ -177,4 +184,9 @@ class _PlaceholderImplementation extends GoogleSignInPlatform { Future disconnect(DisconnectParams params) { throw UnimplementedError(); } + + @override + Future clearAuthCache({required String token}) { + throw UnimplementedError(); + } } 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 c530bd08487..feda3c0a63d 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/packages/tree/main/packages/google_sign_i 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: 3.0.0 +version: 3.0.1 environment: sdk: ^3.7.0 diff --git a/packages/google_sign_in/google_sign_in_web/CHANGELOG.md b/packages/google_sign_in/google_sign_in_web/CHANGELOG.md index 86b1a053fd7..39cb9148870 100644 --- a/packages/google_sign_in/google_sign_in_web/CHANGELOG.md +++ b/packages/google_sign_in/google_sign_in_web/CHANGELOG.md @@ -1,5 +1,6 @@ -## NEXT +## 1.0.1 +* feat(google_sign_in): Add `clearAuthCache` method to remove an access token from the cache. * Updates minimum supported SDK version to Flutter 3.29/Dart 3.7. ## 1.0.0 diff --git a/packages/google_sign_in/google_sign_in_web/example/integration_test/google_sign_in_web_test.dart b/packages/google_sign_in/google_sign_in_web/example/integration_test/google_sign_in_web_test.dart index 57fdaa78986..df7dde2552e 100644 --- a/packages/google_sign_in/google_sign_in_web/example/integration_test/google_sign_in_web_test.dart +++ b/packages/google_sign_in/google_sign_in_web/example/integration_test/google_sign_in_web_test.dart @@ -353,6 +353,22 @@ void main() { ); }); }); + + group('clearAuthCache', () { + const String someToken = '50m3_4cc355_70k3n'; + setUp(() { + plugin.init(options); + }); + + testWidgets('calls clearAuthCache on GIS client', (_) async { + await plugin.clearAuthCache(token: someToken); + + final List arguments = + mockito.verify(mockGis.clearAuthCache(mockito.captureAny)).captured; + + expect(arguments.first, someToken); + }); + }); }); group('userDataEvents', () { diff --git a/packages/google_sign_in/google_sign_in_web/example/pubspec.yaml b/packages/google_sign_in/google_sign_in_web/example/pubspec.yaml index f01050554b5..c37d0001454 100644 --- a/packages/google_sign_in/google_sign_in_web/example/pubspec.yaml +++ b/packages/google_sign_in/google_sign_in_web/example/pubspec.yaml @@ -26,3 +26,7 @@ dev_dependencies: flutter: uses-material-design: true +# FOR TESTING AND INITIAL REVIEW ONLY. DO NOT MERGE. +# See https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins +dependency_overrides: + google_sign_in_platform_interface: {path: ../../../../packages/google_sign_in/google_sign_in_platform_interface} diff --git a/packages/google_sign_in/google_sign_in_web/lib/google_sign_in_web.dart b/packages/google_sign_in/google_sign_in_web/lib/google_sign_in_web.dart index 3142536fb5e..753e9a5400e 100644 --- a/packages/google_sign_in/google_sign_in_web/lib/google_sign_in_web.dart +++ b/packages/google_sign_in/google_sign_in_web/lib/google_sign_in_web.dart @@ -243,6 +243,12 @@ class GoogleSignInPlugin extends GoogleSignInPlatform { ); } + @override + Future clearAuthCache({required String token}) async { + await initialized; + return _gisClient.clearAuthCache(token); + } + @override Stream get authenticationEvents => _authenticationController.stream; diff --git a/packages/google_sign_in/google_sign_in_web/lib/src/gis_client.dart b/packages/google_sign_in/google_sign_in_web/lib/src/gis_client.dart index 159c35e81fc..9823597e1e5 100644 --- a/packages/google_sign_in/google_sign_in_web/lib/src/gis_client.dart +++ b/packages/google_sign_in/google_sign_in_web/lib/src/gis_client.dart @@ -279,6 +279,14 @@ class GisSdkClient { await signOut(); } + /// Clears the authorization cache for the given [token]. + void clearAuthCache(String token) { + _lastClientAuthorizationByUser.removeWhere( + (String? key, (TokenResponse tokenResponse, DateTime expiration) value) => + value.tokenResponse.access_token == token, + ); + } + /// Requests the given list of [scopes], and returns the resulting /// authorization token if successful. /// diff --git a/packages/google_sign_in/google_sign_in_web/pubspec.yaml b/packages/google_sign_in/google_sign_in_web/pubspec.yaml index f53d3f0b213..e3c486c7e9f 100644 --- a/packages/google_sign_in/google_sign_in_web/pubspec.yaml +++ b/packages/google_sign_in/google_sign_in_web/pubspec.yaml @@ -3,7 +3,7 @@ description: Flutter plugin for Google Sign-In, a secure authentication system for signing in with a Google account on Android, iOS and Web. repository: https://github.com/flutter/packages/tree/main/packages/google_sign_in/google_sign_in_web issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+google_sign_in%22 -version: 1.0.0 +version: 1.0.1 environment: sdk: ^3.7.0 @@ -23,7 +23,8 @@ dependencies: flutter_web_plugins: sdk: flutter google_identity_services_web: ^0.3.1 - google_sign_in_platform_interface: ^3.0.0 + google_sign_in_platform_interface: + path: ../google_sign_in_platform_interface http: ">=0.13.0 <2.0.0" web: ">=0.5.1 <2.0.0" diff --git a/script/tool/bin/flutter_plugin_tools.dart b/script/tool/bin/flutter_plugin_tools.dart old mode 100644 new mode 100755 From 92adf689944bb23885088289647d4337f261c335 Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Mon, 18 Aug 2025 08:51:07 -0400 Subject: [PATCH 02/18] Fix versioning --- packages/google_sign_in/google_sign_in/CHANGELOG.md | 5 +++-- packages/google_sign_in/google_sign_in/pubspec.yaml | 2 +- packages/google_sign_in/google_sign_in_android/CHANGELOG.md | 4 ++-- packages/google_sign_in/google_sign_in_android/pubspec.yaml | 2 +- packages/google_sign_in/google_sign_in_ios/CHANGELOG.md | 3 ++- packages/google_sign_in/google_sign_in_ios/pubspec.yaml | 2 +- .../google_sign_in_platform_interface/CHANGELOG.md | 5 +++-- .../google_sign_in_platform_interface/pubspec.yaml | 2 +- packages/google_sign_in/google_sign_in_web/CHANGELOG.md | 4 ++-- packages/google_sign_in/google_sign_in_web/pubspec.yaml | 2 +- 10 files changed, 17 insertions(+), 14 deletions(-) diff --git a/packages/google_sign_in/google_sign_in/CHANGELOG.md b/packages/google_sign_in/google_sign_in/CHANGELOG.md index 4b65fced4ed..d3e6c62eb4c 100644 --- a/packages/google_sign_in/google_sign_in/CHANGELOG.md +++ b/packages/google_sign_in/google_sign_in/CHANGELOG.md @@ -1,6 +1,7 @@ -## 7.1.2 +## 7.2.0 -* feat(google_sign_in): Add `clearAuthCache` method to remove an access token from the cache. +* Adds a `clearAuthorizationToken` method to remove an access token from the + cache. * Updates minimum supported SDK version to Flutter 3.29/Dart 3.7. ## 7.1.1 diff --git a/packages/google_sign_in/google_sign_in/pubspec.yaml b/packages/google_sign_in/google_sign_in/pubspec.yaml index 49a64343612..8786550c363 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 @@ description: Flutter plugin for Google Sign-In, a secure authentication system for signing in with a Google account. repository: https://github.com/flutter/packages/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: 7.1.2 +version: 7.2.0 environment: sdk: ^3.7.0 diff --git a/packages/google_sign_in/google_sign_in_android/CHANGELOG.md b/packages/google_sign_in/google_sign_in_android/CHANGELOG.md index 783a3dd15f2..53aa0efb5b2 100644 --- a/packages/google_sign_in/google_sign_in_android/CHANGELOG.md +++ b/packages/google_sign_in/google_sign_in_android/CHANGELOG.md @@ -1,6 +1,6 @@ -## 7.0.4 +## 7.1.0 -* feat(google_sign_in): Add `clearAuthCache` method to remove an access token from the cache. +* Adds support for the `clearAuthorizationToken` method. * Updates minimum supported SDK version to Flutter 3.29/Dart 3.7. ## 7.0.3 diff --git a/packages/google_sign_in/google_sign_in_android/pubspec.yaml b/packages/google_sign_in/google_sign_in_android/pubspec.yaml index 02d40e17ca1..e44ecc3bb4f 100644 --- a/packages/google_sign_in/google_sign_in_android/pubspec.yaml +++ b/packages/google_sign_in/google_sign_in_android/pubspec.yaml @@ -2,7 +2,7 @@ name: google_sign_in_android description: Android implementation of the google_sign_in plugin. repository: https://github.com/flutter/packages/tree/main/packages/google_sign_in/google_sign_in_android issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+google_sign_in%22 -version: 7.0.4 +version: 7.1.0 environment: sdk: ^3.7.0 diff --git a/packages/google_sign_in/google_sign_in_ios/CHANGELOG.md b/packages/google_sign_in/google_sign_in_ios/CHANGELOG.md index 0934dd32357..8137ea2316c 100644 --- a/packages/google_sign_in/google_sign_in_ios/CHANGELOG.md +++ b/packages/google_sign_in/google_sign_in_ios/CHANGELOG.md @@ -1,5 +1,6 @@ -## NEXT +## 6.2.0 +* Adds support for the `clearAuthorizationToken` method. * Updates minimum supported SDK version to Flutter 3.29/Dart 3.7. ## 6.1.0 diff --git a/packages/google_sign_in/google_sign_in_ios/pubspec.yaml b/packages/google_sign_in/google_sign_in_ios/pubspec.yaml index 6df1b4272a9..858e1af0463 100644 --- a/packages/google_sign_in/google_sign_in_ios/pubspec.yaml +++ b/packages/google_sign_in/google_sign_in_ios/pubspec.yaml @@ -2,7 +2,7 @@ name: google_sign_in_ios description: iOS implementation of the google_sign_in plugin. repository: https://github.com/flutter/packages/tree/main/packages/google_sign_in/google_sign_in_ios issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+google_sign_in%22 -version: 6.1.0 +version: 6.2.0 environment: sdk: ^3.7.0 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 ce1bd804252..5ba9a7471ae 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,6 +1,7 @@ -## 3.0.1 +## 3.1.0 -* feat(google_sign_in): Add `clearAuthCache` method to remove an access token from the cache. +* Adds a `clearAuthorizationToken` method to remove an access token from the + cache. * Updates minimum supported SDK version to Flutter 3.29/Dart 3.7. ## 3.0.0 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 feda3c0a63d..6d6037ee0ed 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/packages/tree/main/packages/google_sign_i 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: 3.0.1 +version: 3.1.0 environment: sdk: ^3.7.0 diff --git a/packages/google_sign_in/google_sign_in_web/CHANGELOG.md b/packages/google_sign_in/google_sign_in_web/CHANGELOG.md index 39cb9148870..61adeae6f5e 100644 --- a/packages/google_sign_in/google_sign_in_web/CHANGELOG.md +++ b/packages/google_sign_in/google_sign_in_web/CHANGELOG.md @@ -1,6 +1,6 @@ -## 1.0.1 +## 1.1.0 -* feat(google_sign_in): Add `clearAuthCache` method to remove an access token from the cache. +* Adds support for the `clearAuthorizationToken` method. * Updates minimum supported SDK version to Flutter 3.29/Dart 3.7. ## 1.0.0 diff --git a/packages/google_sign_in/google_sign_in_web/pubspec.yaml b/packages/google_sign_in/google_sign_in_web/pubspec.yaml index e3c486c7e9f..42129e55ef3 100644 --- a/packages/google_sign_in/google_sign_in_web/pubspec.yaml +++ b/packages/google_sign_in/google_sign_in_web/pubspec.yaml @@ -3,7 +3,7 @@ description: Flutter plugin for Google Sign-In, a secure authentication system for signing in with a Google account on Android, iOS and Web. repository: https://github.com/flutter/packages/tree/main/packages/google_sign_in/google_sign_in_web issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+google_sign_in%22 -version: 1.0.1 +version: 1.1.0 environment: sdk: ^3.7.0 From 9e47e90c5321904368658a100b0df0e4e90e43fe Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Mon, 18 Aug 2025 08:55:51 -0400 Subject: [PATCH 03/18] Rename new method --- .../google_sign_in/lib/google_sign_in.dart | 4 ++-- .../google_sign_in/test/google_sign_in_test.mocks.dart | 4 ++-- .../plugins/googlesignin/GoogleSignInPlugin.java | 5 +++-- .../kotlin/io/flutter/plugins/googlesignin/Messages.kt | 6 +++--- .../flutter/plugins/googlesignin/GoogleSignInTest.java | 4 ++-- .../lib/google_sign_in_android.dart | 4 ++-- .../google_sign_in_android/lib/src/messages.g.dart | 4 ++-- .../google_sign_in_android/pigeons/messages.dart | 2 +- .../test/google_sign_in_android_test.mocks.dart | 4 ++-- .../lib/google_sign_in_platform_interface.dart | 10 ++++++---- .../integration_test/google_sign_in_web_test.dart | 10 ++++++---- .../google_sign_in_web/lib/google_sign_in_web.dart | 4 ++-- .../google_sign_in_web/lib/src/gis_client.dart | 2 +- 13 files changed, 34 insertions(+), 29 deletions(-) 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 6dca4fb4be9..c615e332f37 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 @@ -585,7 +585,7 @@ class GoogleSignIn { /// /// This should be called on any client that has received an access token that /// is no longer valid. - Future clearAuthCache({required String token}) { - return GoogleSignInPlatform.instance.clearAuthCache(token: token); + Future clearAuthorizationToken({required String token}) { + return GoogleSignInPlatform.instance.clearAuthorizationToken(token: token); } } diff --git a/packages/google_sign_in/google_sign_in/test/google_sign_in_test.mocks.dart b/packages/google_sign_in/google_sign_in/test/google_sign_in_test.mocks.dart index e1678bfa772..ccb5d5336a2 100644 --- a/packages/google_sign_in/google_sign_in/test/google_sign_in_test.mocks.dart +++ b/packages/google_sign_in/google_sign_in/test/google_sign_in_test.mocks.dart @@ -129,9 +129,9 @@ class MockGoogleSignInPlatform extends _i1.Mock as _i4.Future); @override - _i4.Future clearAuthCache({required String? token}) => + _i4.Future clearAuthorizationToken({required String? token}) => (super.noSuchMethod( - Invocation.method(#clearAuthCache, [], {#token: token}), + Invocation.method(#clearAuthorizationToken, [], {#token: token}), returnValue: _i4.Future.value(), returnValueForMissingStub: _i4.Future.value(), ) diff --git a/packages/google_sign_in/google_sign_in_android/android/src/main/java/io/flutter/plugins/googlesignin/GoogleSignInPlugin.java b/packages/google_sign_in/google_sign_in_android/android/src/main/java/io/flutter/plugins/googlesignin/GoogleSignInPlugin.java index c9aa89ad4d1..bca07948228 100644 --- a/packages/google_sign_in/google_sign_in_android/android/src/main/java/io/flutter/plugins/googlesignin/GoogleSignInPlugin.java +++ b/packages/google_sign_in/google_sign_in_android/android/src/main/java/io/flutter/plugins/googlesignin/GoogleSignInPlugin.java @@ -343,7 +343,7 @@ public void onError(@NonNull ClearCredentialException e) { } @Override - public void clearAuthCache( + public void clearAuthorizationToken( @NonNull String token, @NonNull Function1, Unit> callback) { authorizationClientFactory .create(context) @@ -355,7 +355,8 @@ public void clearAuthCache( .addOnFailureListener( (Exception e) -> { ResultUtilsKt.completeWithFlutterError( - callback, new FlutterError("clearAuthCacheFailed", e.getMessage(), null)); + callback, + new FlutterError("clearAuthorizationToken failed", e.getMessage(), null)); }); } diff --git a/packages/google_sign_in/google_sign_in_android/android/src/main/kotlin/io/flutter/plugins/googlesignin/Messages.kt b/packages/google_sign_in/google_sign_in_android/android/src/main/kotlin/io/flutter/plugins/googlesignin/Messages.kt index 9b6402e00c4..d0f8e1cc931 100644 --- a/packages/google_sign_in/google_sign_in_android/android/src/main/kotlin/io/flutter/plugins/googlesignin/Messages.kt +++ b/packages/google_sign_in/google_sign_in_android/android/src/main/kotlin/io/flutter/plugins/googlesignin/Messages.kt @@ -478,7 +478,7 @@ interface GoogleSignInApi { /** Clears CredentialManager credential state. */ fun clearCredentialState(callback: (Result) -> Unit) /** Clears the authorization cache for the given token. */ - fun clearAuthCache(token: String, callback: (Result) -> Unit) + fun clearAuthorizationToken(token: String, callback: (Result) -> Unit) /** Requests authorization tokens via AuthorizationClient. */ fun authorize( params: PlatformAuthorizationRequest, @@ -569,13 +569,13 @@ interface GoogleSignInApi { val channel = BasicMessageChannel( binaryMessenger, - "dev.flutter.pigeon.google_sign_in_android.GoogleSignInApi.clearAuthCache$separatedMessageChannelSuffix", + "dev.flutter.pigeon.google_sign_in_android.GoogleSignInApi.clearAuthorizationToken$separatedMessageChannelSuffix", codec) if (api != null) { channel.setMessageHandler { message, reply -> val args = message as List val tokenArg = args[0] as String - api.clearAuthCache(tokenArg) { result: Result -> + api.clearAuthorizationToken(tokenArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { reply.reply(wrapError(error)) diff --git a/packages/google_sign_in/google_sign_in_android/android/src/test/java/io/flutter/plugins/googlesignin/GoogleSignInTest.java b/packages/google_sign_in/google_sign_in_android/android/src/test/java/io/flutter/plugins/googlesignin/GoogleSignInTest.java index 31c59c27eaa..869fcdd39a7 100644 --- a/packages/google_sign_in/google_sign_in_android/android/src/test/java/io/flutter/plugins/googlesignin/GoogleSignInTest.java +++ b/packages/google_sign_in/google_sign_in_android/android/src/test/java/io/flutter/plugins/googlesignin/GoogleSignInTest.java @@ -1099,10 +1099,10 @@ public void clearCredentialState_reportsFailure() { } @Test - public void clearAuthCache_callsClient() { + public void clearAuthorizationToken_callsClient() { final Task mockTask = mock(Task.class); when(mockAuthorizationClient.clearToken(any())).thenReturn(mockTask); - plugin.clearAuthCache( + plugin.clearAuthorizationToken( "test_token", ResultCompat.asCompatCallback( reply -> { diff --git a/packages/google_sign_in/google_sign_in_android/lib/google_sign_in_android.dart b/packages/google_sign_in/google_sign_in_android/lib/google_sign_in_android.dart index e7918d9292f..51ce57c4a2f 100644 --- a/packages/google_sign_in/google_sign_in_android/lib/google_sign_in_android.dart +++ b/packages/google_sign_in/google_sign_in_android/lib/google_sign_in_android.dart @@ -28,8 +28,8 @@ class GoogleSignInAndroid extends GoogleSignInPlatform { } @override - Future clearAuthCache({required String token}) { - return _hostApi.clearAuthCache(token); + Future clearAuthorizationToken({required String token}) { + return _hostApi.clearAuthorizationToken(token); } @override diff --git a/packages/google_sign_in/google_sign_in_android/lib/src/messages.g.dart b/packages/google_sign_in/google_sign_in_android/lib/src/messages.g.dart index 9330273acfe..74709b9ec11 100644 --- a/packages/google_sign_in/google_sign_in_android/lib/src/messages.g.dart +++ b/packages/google_sign_in/google_sign_in_android/lib/src/messages.g.dart @@ -526,9 +526,9 @@ class GoogleSignInApi { } /// Clears the authorization cache for the given token. - Future clearAuthCache(String token) async { + Future clearAuthorizationToken(String token) async { final String pigeonVar_channelName = - 'dev.flutter.pigeon.google_sign_in_android.GoogleSignInApi.clearAuthCache$pigeonVar_messageChannelSuffix'; + 'dev.flutter.pigeon.google_sign_in_android.GoogleSignInApi.clearAuthorizationToken$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, diff --git a/packages/google_sign_in/google_sign_in_android/pigeons/messages.dart b/packages/google_sign_in/google_sign_in_android/pigeons/messages.dart index bbc47d1a711..4bbeeeb10e1 100644 --- a/packages/google_sign_in/google_sign_in_android/pigeons/messages.dart +++ b/packages/google_sign_in/google_sign_in_android/pigeons/messages.dart @@ -196,7 +196,7 @@ abstract class GoogleSignInApi { /// Clears the authorization cache for the given token. @async - void clearAuthCache(String token); + void clearAuthorizationToken(String token); /// Requests authorization tokens via AuthorizationClient. @async diff --git a/packages/google_sign_in/google_sign_in_android/test/google_sign_in_android_test.mocks.dart b/packages/google_sign_in/google_sign_in_android/test/google_sign_in_android_test.mocks.dart index 618bad201a1..5acdee9fd5e 100644 --- a/packages/google_sign_in/google_sign_in_android/test/google_sign_in_android_test.mocks.dart +++ b/packages/google_sign_in/google_sign_in_android/test/google_sign_in_android_test.mocks.dart @@ -83,9 +83,9 @@ class MockGoogleSignInApi extends _i1.Mock implements _i2.GoogleSignInApi { as _i4.Future); @override - _i4.Future clearAuthCache(String? token) => + _i4.Future clearAuthorizationToken(String? token) => (super.noSuchMethod( - Invocation.method(#clearAuthCache, [token]), + Invocation.method(#clearAuthorizationToken, [token]), returnValue: _i4.Future.value(), returnValueForMissingStub: _i4.Future.value(), ) diff --git a/packages/google_sign_in/google_sign_in_platform_interface/lib/google_sign_in_platform_interface.dart b/packages/google_sign_in/google_sign_in_platform_interface/lib/google_sign_in_platform_interface.dart index 4adf2d96f1a..5328814fa14 100644 --- a/packages/google_sign_in/google_sign_in_platform_interface/lib/google_sign_in_platform_interface.dart +++ b/packages/google_sign_in/google_sign_in_platform_interface/lib/google_sign_in_platform_interface.dart @@ -105,11 +105,13 @@ abstract class GoogleSignInPlatform extends PlatformInterface { /// them out. Future disconnect(DisconnectParams params); - /// Clears the token cache for the given `token`. + /// Clears the token cache for the given access token. /// /// How this is implemented is up to the platform. - Future clearAuthCache({required String token}) { - throw UnimplementedError('clearAuthCache() has not been implemented.'); + Future clearAuthorizationToken({required String token}) { + throw UnimplementedError( + 'clearAuthorizationToken() has not been implemented.', + ); } /// Returns a stream of authentication events. @@ -186,7 +188,7 @@ class _PlaceholderImplementation extends GoogleSignInPlatform { } @override - Future clearAuthCache({required String token}) { + Future clearAuthorizationToken({required String token}) { throw UnimplementedError(); } } diff --git a/packages/google_sign_in/google_sign_in_web/example/integration_test/google_sign_in_web_test.dart b/packages/google_sign_in/google_sign_in_web/example/integration_test/google_sign_in_web_test.dart index df7dde2552e..4a27ec83ca4 100644 --- a/packages/google_sign_in/google_sign_in_web/example/integration_test/google_sign_in_web_test.dart +++ b/packages/google_sign_in/google_sign_in_web/example/integration_test/google_sign_in_web_test.dart @@ -354,17 +354,19 @@ void main() { }); }); - group('clearAuthCache', () { + group('clearAuthorizationToken', () { const String someToken = '50m3_4cc355_70k3n'; setUp(() { plugin.init(options); }); - testWidgets('calls clearAuthCache on GIS client', (_) async { - await plugin.clearAuthCache(token: someToken); + testWidgets('calls clearAuthorizationToken on GIS client', (_) async { + await plugin.clearAuthorizationToken(token: someToken); final List arguments = - mockito.verify(mockGis.clearAuthCache(mockito.captureAny)).captured; + mockito + .verify(mockGis.clearAuthorizationToken(mockito.captureAny)) + .captured; expect(arguments.first, someToken); }); diff --git a/packages/google_sign_in/google_sign_in_web/lib/google_sign_in_web.dart b/packages/google_sign_in/google_sign_in_web/lib/google_sign_in_web.dart index 753e9a5400e..e71185365b9 100644 --- a/packages/google_sign_in/google_sign_in_web/lib/google_sign_in_web.dart +++ b/packages/google_sign_in/google_sign_in_web/lib/google_sign_in_web.dart @@ -244,9 +244,9 @@ class GoogleSignInPlugin extends GoogleSignInPlatform { } @override - Future clearAuthCache({required String token}) async { + Future clearAuthorizationToken({required String token}) async { await initialized; - return _gisClient.clearAuthCache(token); + return _gisClient.clearAuthorizationToken(token); } @override diff --git a/packages/google_sign_in/google_sign_in_web/lib/src/gis_client.dart b/packages/google_sign_in/google_sign_in_web/lib/src/gis_client.dart index 9823597e1e5..0132bc2e7ad 100644 --- a/packages/google_sign_in/google_sign_in_web/lib/src/gis_client.dart +++ b/packages/google_sign_in/google_sign_in_web/lib/src/gis_client.dart @@ -280,7 +280,7 @@ class GisSdkClient { } /// Clears the authorization cache for the given [token]. - void clearAuthCache(String token) { + void clearAuthorizationToken(String token) { _lastClientAuthorizationByUser.removeWhere( (String? key, (TokenResponse tokenResponse, DateTime expiration) value) => value.tokenResponse.access_token == token, From 0666ee9bb1388637d5a5ba23a8ac8d12070cc0ae Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Mon, 18 Aug 2025 09:05:12 -0400 Subject: [PATCH 04/18] Move the app-facing method to the authorization client, and improve docs --- .../google_sign_in/lib/google_sign_in.dart | 42 ++++++++++++------- 1 file changed, 27 insertions(+), 15 deletions(-) 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 c615e332f37..10f491f7a88 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 @@ -136,6 +136,9 @@ class GoogleSignInAuthorizationClient { /// /// If authorization would require user interaction, this returns null, in /// which case [authorizeScopes] should be used instead. + /// + /// In rare cases, this can return tokens that are no longer valid. See + /// [clearAuthorizationToken] for details. Future authorizationForScopes( List scopes, ) async { @@ -150,6 +153,9 @@ class GoogleSignInAuthorizationClient { /// allowed (for example, while the app is foregrounded on mobile), and if /// [GoogleSignIn.authorizationRequiresUserInteraction] returns true this /// should only be called from an user interaction handler. + /// + /// In rare cases, this can return tokens that are no longer valid. See + /// [clearAuthorizationToken] for details. Future authorizeScopes( List scopes, ) async { @@ -173,8 +179,10 @@ class GoogleSignInAuthorizationClient { /// authorization headers, containing the access token for the given scopes. /// /// Returns null if the given scopes are not authorized, or there is no - /// currently valid authorization token available, and - /// [promptIfNecessary] is false. + /// unexpired authorization token available, and [promptIfNecessary] is false. + /// + /// In rare cases, this can return tokens that are no longer valid. See + /// [clearAuthorizationToken] for details. /// /// See also https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Authorization. Future?> authorizationHeaders( @@ -207,6 +215,9 @@ class GoogleSignInAuthorizationClient { /// allowed (for example, while the app is foregrounded on mobile), and if /// [GoogleSignIn.authorizationRequiresUserInteraction] returns true this /// should only be called from an user interaction handler. + /// + /// In rare cases, this can return tokens that are no longer valid. See + /// [clearAuthorizationToken] for details. Future authorizeServer( List scopes, ) async { @@ -229,6 +240,20 @@ class GoogleSignInAuthorizationClient { ); } + /// Removes the given [accessToken] from any local authorization caches. + /// + /// This should be called if using an access token results in an invalid token + /// response from the target API, followed by re-requsting authorization. + /// + /// A token can be invalidated by, for example, a user removing an + /// application's authorization from outside of the application: + /// https://support.google.com/accounts/answer/13533235. + Future clearAuthorizationToken({required String accessToken}) { + return GoogleSignInPlatform.instance.clearAuthorizationToken( + token: accessToken, + ); + } + Future _authorizeClient( List scopes, { required bool promptIfUnauthorized, @@ -575,17 +600,4 @@ class GoogleSignIn { // single user at a time, so the distinction is mostly theoretical for now. await GoogleSignInPlatform.instance.disconnect(const DisconnectParams()); } - - /// Clears the authentication cache of the specified token. - /// - /// How this method works depends on the platform: - /// - /// - On Android, this will attempt to clear the token from the cache. - /// - On Web, this will remove any matching entry from the token cache. - /// - /// This should be called on any client that has received an access token that - /// is no longer valid. - Future clearAuthorizationToken({required String token}) { - return GoogleSignInPlatform.instance.clearAuthorizationToken(token: token); - } } From 83be0046606a2e6d494d344f7b44efe96f98eb66 Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Mon, 18 Aug 2025 09:06:14 -0400 Subject: [PATCH 05/18] Update migration guide --- packages/google_sign_in/google_sign_in/MIGRATION.md | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/google_sign_in/google_sign_in/MIGRATION.md b/packages/google_sign_in/google_sign_in/MIGRATION.md index 03b627bbe22..524fd1266c1 100644 --- a/packages/google_sign_in/google_sign_in/MIGRATION.md +++ b/packages/google_sign_in/google_sign_in/MIGRATION.md @@ -61,6 +61,7 @@ include: publishing, the only platform that does not support `authenticate` is web, where `google_sign_in_web`'s `renderButton` is used to create a sign-in button. +* `clearAuthCache` has been replaced by `clearAuthorizationToken`. * Outcomes other than successful authentication or authorization will throw `GoogleSignInException`s in most cases, allowing a clear way to distinguish different sign in failure outcomes. This includes the user canceling From f8c562545f01c7846a57def79eedc4445266bb2e Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Mon, 18 Aug 2025 09:13:34 -0400 Subject: [PATCH 06/18] Add a no-op on iOS --- .../google_sign_in_ios/lib/google_sign_in_ios.dart | 5 +++++ .../google_sign_in_ios/test/google_sign_in_ios_test.dart | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/packages/google_sign_in/google_sign_in_ios/lib/google_sign_in_ios.dart b/packages/google_sign_in/google_sign_in_ios/lib/google_sign_in_ios.dart index 5c8cbc2dd2c..15e3ffd4d64 100644 --- a/packages/google_sign_in/google_sign_in_ios/lib/google_sign_in_ios.dart +++ b/packages/google_sign_in/google_sign_in_ios/lib/google_sign_in_ios.dart @@ -134,6 +134,11 @@ class GoogleSignInIOS extends GoogleSignInPlatform { : ServerAuthorizationTokenData(serverAuthCode: serverAuthCode); } + @override + Future clearAuthorizationToken({required String token}) async { + // No-op; the iOS SDK handles token invalidation internally. + } + Future<({String? accessToken, String? serverAuthCode})> _getAuthorizationTokens(AuthorizationRequestDetails request) async { String? userId = request.userId; diff --git a/packages/google_sign_in/google_sign_in_ios/test/google_sign_in_ios_test.dart b/packages/google_sign_in/google_sign_in_ios/test/google_sign_in_ios_test.dart index e258b4dd7d1..d8016d3e65e 100644 --- a/packages/google_sign_in/google_sign_in_ios/test/google_sign_in_ios_test.dart +++ b/packages/google_sign_in/google_sign_in_ios/test/google_sign_in_ios_test.dart @@ -1232,6 +1232,12 @@ void main() { verifyInOrder(>[mockApi.disconnect(), mockApi.signOut()]); }); + test('clearAuthorizationToken no-ops without error', () async { + await googleSignIn.clearAuthorizationToken(token: 'any token'); + + verifyZeroInteractions(mockApi); + }); + // Returning null triggers the app-facing package to create stream events, // per GoogleSignInPlatform docs, so it's important that this returns null // unless the platform implementation is changed to create all necessary From e4a08c6b908573512287691c8d8471518d23ba67 Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Mon, 18 Aug 2025 09:19:21 -0400 Subject: [PATCH 07/18] Fix up path overrides --- .../google_sign_in/example/pubspec.yaml | 3 +++ .../google_sign_in/pubspec.yaml | 19 +++++++++++-------- .../google_sign_in_android/pubspec.yaml | 7 +++++-- .../google_sign_in_ios/pubspec.yaml | 7 +++++-- .../google_sign_in_web/pubspec.yaml | 7 +++++-- 5 files changed, 29 insertions(+), 14 deletions(-) diff --git a/packages/google_sign_in/google_sign_in/example/pubspec.yaml b/packages/google_sign_in/google_sign_in/example/pubspec.yaml index 3b9e6f214cc..430cf8de953 100644 --- a/packages/google_sign_in/google_sign_in/example/pubspec.yaml +++ b/packages/google_sign_in/google_sign_in/example/pubspec.yaml @@ -31,4 +31,7 @@ flutter: # FOR TESTING AND INITIAL REVIEW ONLY. DO NOT MERGE. # See https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins dependency_overrides: + google_sign_in_android: {path: ../../../../packages/google_sign_in/google_sign_in_android} + google_sign_in_ios: {path: ../../../../packages/google_sign_in/google_sign_in_ios} + google_sign_in_platform_interface: {path: ../../../../packages/google_sign_in/google_sign_in_platform_interface} google_sign_in_web: {path: ../../../../packages/google_sign_in/google_sign_in_web} diff --git a/packages/google_sign_in/google_sign_in/pubspec.yaml b/packages/google_sign_in/google_sign_in/pubspec.yaml index 8786550c363..3434920c6ca 100644 --- a/packages/google_sign_in/google_sign_in/pubspec.yaml +++ b/packages/google_sign_in/google_sign_in/pubspec.yaml @@ -24,14 +24,10 @@ flutter: dependencies: flutter: sdk: flutter - google_sign_in_android: - path: ../google_sign_in_android - google_sign_in_ios: - path: ../google_sign_in_ios - google_sign_in_platform_interface: - path: ../google_sign_in_platform_interface - google_sign_in_web: - path: ../google_sign_in_web + google_sign_in_android: ^7.0.0 + google_sign_in_ios: ^6.0.0 + google_sign_in_platform_interface: ^3.0.0 + google_sign_in_web: ^1.0.0 dev_dependencies: build_runner: ^2.1.10 @@ -52,3 +48,10 @@ false_secrets: - /example/ios/RunnerTests/GoogleService-Info.plist - /example/ios/RunnerTests/GoogleSignInTests.m - /example/macos/Runner/Info.plist +# FOR TESTING AND INITIAL REVIEW ONLY. DO NOT MERGE. +# See https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins +dependency_overrides: + google_sign_in_android: {path: ../../../packages/google_sign_in/google_sign_in_android} + google_sign_in_ios: {path: ../../../packages/google_sign_in/google_sign_in_ios} + google_sign_in_platform_interface: {path: ../../../packages/google_sign_in/google_sign_in_platform_interface} + google_sign_in_web: {path: ../../../packages/google_sign_in/google_sign_in_web} diff --git a/packages/google_sign_in/google_sign_in_android/pubspec.yaml b/packages/google_sign_in/google_sign_in_android/pubspec.yaml index e44ecc3bb4f..0df19dbe97d 100644 --- a/packages/google_sign_in/google_sign_in_android/pubspec.yaml +++ b/packages/google_sign_in/google_sign_in_android/pubspec.yaml @@ -20,8 +20,7 @@ flutter: dependencies: flutter: sdk: flutter - google_sign_in_platform_interface: - path: ../google_sign_in_platform_interface + google_sign_in_platform_interface: ^3.0.0 dev_dependencies: build_runner: ^2.3.0 @@ -38,3 +37,7 @@ topics: false_secrets: - /example/android/app/google-services.json - /example/lib/main.dart +# FOR TESTING AND INITIAL REVIEW ONLY. DO NOT MERGE. +# See https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins +dependency_overrides: + google_sign_in_platform_interface: {path: ../../../packages/google_sign_in/google_sign_in_platform_interface} diff --git a/packages/google_sign_in/google_sign_in_ios/pubspec.yaml b/packages/google_sign_in/google_sign_in_ios/pubspec.yaml index 858e1af0463..1433e356eb6 100644 --- a/packages/google_sign_in/google_sign_in_ios/pubspec.yaml +++ b/packages/google_sign_in/google_sign_in_ios/pubspec.yaml @@ -24,8 +24,7 @@ flutter: dependencies: flutter: sdk: flutter - google_sign_in_platform_interface: - path: ../google_sign_in_platform_interface + google_sign_in_platform_interface: ^3.0.0 dev_dependencies: build_runner: ^2.4.6 @@ -45,3 +44,7 @@ false_secrets: - /example/ios/Runner/Info.plist - /example/lib/main.dart - /example/macos/Runner/Info.plist +# FOR TESTING AND INITIAL REVIEW ONLY. DO NOT MERGE. +# See https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins +dependency_overrides: + google_sign_in_platform_interface: {path: ../../../packages/google_sign_in/google_sign_in_platform_interface} diff --git a/packages/google_sign_in/google_sign_in_web/pubspec.yaml b/packages/google_sign_in/google_sign_in_web/pubspec.yaml index 42129e55ef3..5700c7226f1 100644 --- a/packages/google_sign_in/google_sign_in_web/pubspec.yaml +++ b/packages/google_sign_in/google_sign_in_web/pubspec.yaml @@ -23,8 +23,7 @@ dependencies: flutter_web_plugins: sdk: flutter google_identity_services_web: ^0.3.1 - google_sign_in_platform_interface: - path: ../google_sign_in_platform_interface + google_sign_in_platform_interface: ^3.0.0 http: ">=0.13.0 <2.0.0" web: ">=0.5.1 <2.0.0" @@ -35,3 +34,7 @@ dev_dependencies: topics: - authentication - google-sign-in +# FOR TESTING AND INITIAL REVIEW ONLY. DO NOT MERGE. +# See https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins +dependency_overrides: + google_sign_in_platform_interface: {path: ../../../packages/google_sign_in/google_sign_in_platform_interface} From 04d1cb83c1cecddab38c179d1d8596beaad89342 Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Mon, 18 Aug 2025 10:45:59 -0400 Subject: [PATCH 08/18] Parameter object --- .../google_sign_in/lib/google_sign_in.dart | 2 +- .../test/google_sign_in_test.mocks.dart | 14 ++++++----- .../lib/google_sign_in_android.dart | 4 ++-- .../lib/google_sign_in_ios.dart | 4 +++- .../test/google_sign_in_ios_test.dart | 4 +++- .../test/google_sign_in_ios_test.mocks.dart | 2 +- .../google_sign_in_platform_interface.dart | 22 ++++++++---------- .../lib/src/types.dart | 23 +++++++++++++++++++ .../google_sign_in_web_test.dart | 6 +++-- .../google_sign_in_web_test.mocks.dart | 8 ++++++- .../integration_test/web_only_test.mocks.dart | 8 ++++++- .../lib/google_sign_in_web.dart | 6 +++-- .../lib/src/gis_client.dart | 2 +- 13 files changed, 74 insertions(+), 31 deletions(-) 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 10f491f7a88..3a1804cf242 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 @@ -250,7 +250,7 @@ class GoogleSignInAuthorizationClient { /// https://support.google.com/accounts/answer/13533235. Future clearAuthorizationToken({required String accessToken}) { return GoogleSignInPlatform.instance.clearAuthorizationToken( - token: accessToken, + ClearAuthorizationTokensParams(accessToken: accessToken), ); } diff --git a/packages/google_sign_in/google_sign_in/test/google_sign_in_test.mocks.dart b/packages/google_sign_in/google_sign_in/test/google_sign_in_test.mocks.dart index ccb5d5336a2..e3e9d156b7e 100644 --- a/packages/google_sign_in/google_sign_in/test/google_sign_in_test.mocks.dart +++ b/packages/google_sign_in/google_sign_in/test/google_sign_in_test.mocks.dart @@ -111,27 +111,29 @@ class MockGoogleSignInPlatform extends _i1.Mock as _i4.Future<_i2.ServerAuthorizationTokenData?>); @override - _i4.Future signOut(_i2.SignOutParams? params) => + _i4.Future clearAuthorizationToken( + _i2.ClearAuthorizationTokensParams? params, + ) => (super.noSuchMethod( - Invocation.method(#signOut, [params]), + Invocation.method(#clearAuthorizationToken, [params]), returnValue: _i4.Future.value(), returnValueForMissingStub: _i4.Future.value(), ) as _i4.Future); @override - _i4.Future disconnect(_i2.DisconnectParams? params) => + _i4.Future signOut(_i2.SignOutParams? params) => (super.noSuchMethod( - Invocation.method(#disconnect, [params]), + Invocation.method(#signOut, [params]), returnValue: _i4.Future.value(), returnValueForMissingStub: _i4.Future.value(), ) as _i4.Future); @override - _i4.Future clearAuthorizationToken({required String? token}) => + _i4.Future disconnect(_i2.DisconnectParams? params) => (super.noSuchMethod( - Invocation.method(#clearAuthorizationToken, [], {#token: token}), + Invocation.method(#disconnect, [params]), returnValue: _i4.Future.value(), returnValueForMissingStub: _i4.Future.value(), ) diff --git a/packages/google_sign_in/google_sign_in_android/lib/google_sign_in_android.dart b/packages/google_sign_in/google_sign_in_android/lib/google_sign_in_android.dart index 51ce57c4a2f..42de315a2d2 100644 --- a/packages/google_sign_in/google_sign_in_android/lib/google_sign_in_android.dart +++ b/packages/google_sign_in/google_sign_in_android/lib/google_sign_in_android.dart @@ -28,8 +28,8 @@ class GoogleSignInAndroid extends GoogleSignInPlatform { } @override - Future clearAuthorizationToken({required String token}) { - return _hostApi.clearAuthorizationToken(token); + Future clearAuthorizationToken(ClearAuthorizationTokensParams params) { + return _hostApi.clearAuthorizationToken(params.accessToken); } @override diff --git a/packages/google_sign_in/google_sign_in_ios/lib/google_sign_in_ios.dart b/packages/google_sign_in/google_sign_in_ios/lib/google_sign_in_ios.dart index 15e3ffd4d64..4b850ee297a 100644 --- a/packages/google_sign_in/google_sign_in_ios/lib/google_sign_in_ios.dart +++ b/packages/google_sign_in/google_sign_in_ios/lib/google_sign_in_ios.dart @@ -135,7 +135,9 @@ class GoogleSignInIOS extends GoogleSignInPlatform { } @override - Future clearAuthorizationToken({required String token}) async { + Future clearAuthorizationToken( + ClearAuthorizationTokensParams params, + ) async { // No-op; the iOS SDK handles token invalidation internally. } diff --git a/packages/google_sign_in/google_sign_in_ios/test/google_sign_in_ios_test.dart b/packages/google_sign_in/google_sign_in_ios/test/google_sign_in_ios_test.dart index d8016d3e65e..afde51bb03b 100644 --- a/packages/google_sign_in/google_sign_in_ios/test/google_sign_in_ios_test.dart +++ b/packages/google_sign_in/google_sign_in_ios/test/google_sign_in_ios_test.dart @@ -1233,7 +1233,9 @@ void main() { }); test('clearAuthorizationToken no-ops without error', () async { - await googleSignIn.clearAuthorizationToken(token: 'any token'); + await googleSignIn.clearAuthorizationToken( + const ClearAuthorizationTokensParams(accessToken: 'any token'), + ); verifyZeroInteractions(mockApi); }); diff --git a/packages/google_sign_in/google_sign_in_ios/test/google_sign_in_ios_test.mocks.dart b/packages/google_sign_in/google_sign_in_ios/test/google_sign_in_ios_test.mocks.dart index 5ffcbc9c631..fd93477a6d5 100644 --- a/packages/google_sign_in/google_sign_in_ios/test/google_sign_in_ios_test.mocks.dart +++ b/packages/google_sign_in/google_sign_in_ios/test/google_sign_in_ios_test.mocks.dart @@ -1,4 +1,4 @@ -// Mocks generated by Mockito 5.4.5 from annotations +// Mocks generated by Mockito 5.4.6 from annotations // in google_sign_in_ios/test/google_sign_in_ios_test.dart. // Do not manually edit this file. diff --git a/packages/google_sign_in/google_sign_in_platform_interface/lib/google_sign_in_platform_interface.dart b/packages/google_sign_in/google_sign_in_platform_interface/lib/google_sign_in_platform_interface.dart index 5328814fa14..ca4f36d81f9 100644 --- a/packages/google_sign_in/google_sign_in_platform_interface/lib/google_sign_in_platform_interface.dart +++ b/packages/google_sign_in/google_sign_in_platform_interface/lib/google_sign_in_platform_interface.dart @@ -98,6 +98,13 @@ abstract class GoogleSignInPlatform extends PlatformInterface { ServerAuthorizationTokensForScopesParameters params, ); + /// Clears any token cache for the given access token. + Future clearAuthorizationToken(ClearAuthorizationTokensParams params) { + throw UnimplementedError( + 'clearAuthorizationToken() has not been implemented.', + ); + } + /// Signs out previously signed in accounts. Future signOut(SignOutParams params); @@ -105,15 +112,6 @@ abstract class GoogleSignInPlatform extends PlatformInterface { /// them out. Future disconnect(DisconnectParams params); - /// Clears the token cache for the given access token. - /// - /// How this is implemented is up to the platform. - Future clearAuthorizationToken({required String token}) { - throw UnimplementedError( - 'clearAuthorizationToken() has not been implemented.', - ); - } - /// Returns a stream of authentication events. /// /// If this is not overridden, the app-facing package will assume that the @@ -178,17 +176,17 @@ class _PlaceholderImplementation extends GoogleSignInPlatform { } @override - Future signOut(SignOutParams params) { + Future clearAuthorizationToken(ClearAuthorizationTokensParams params) { throw UnimplementedError(); } @override - Future disconnect(DisconnectParams params) { + Future signOut(SignOutParams params) { throw UnimplementedError(); } @override - Future clearAuthorizationToken({required String token}) { + Future disconnect(DisconnectParams params) { throw UnimplementedError(); } } 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 fca3a630692..e4565d4d7b8 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 @@ -363,6 +363,29 @@ class AuthenticationResults { final AuthenticationTokenData authenticationTokens; } +/// Parameters for the clearAuthorizationTokens method. +@immutable +class ClearAuthorizationTokensParams { + /// Creates new parameters for clearAuthorizationTokens with the given + /// [accessToken] + const ClearAuthorizationTokensParams({required this.accessToken}); + + /// The OAuth2 access token to clear. + final String accessToken; + + @override + int get hashCode => accessToken.hashCode; + + @override + bool operator ==(Object other) { + if (other.runtimeType != runtimeType) { + return false; + } + return other is ClearAuthorizationTokensParams && + other.accessToken == accessToken; + } +} + /// Parameters for the signOut method. @immutable class SignOutParams { diff --git a/packages/google_sign_in/google_sign_in_web/example/integration_test/google_sign_in_web_test.dart b/packages/google_sign_in/google_sign_in_web/example/integration_test/google_sign_in_web_test.dart index 4a27ec83ca4..0433872b95e 100644 --- a/packages/google_sign_in/google_sign_in_web/example/integration_test/google_sign_in_web_test.dart +++ b/packages/google_sign_in/google_sign_in_web/example/integration_test/google_sign_in_web_test.dart @@ -355,13 +355,15 @@ void main() { }); group('clearAuthorizationToken', () { - const String someToken = '50m3_4cc355_70k3n'; setUp(() { plugin.init(options); }); testWidgets('calls clearAuthorizationToken on GIS client', (_) async { - await plugin.clearAuthorizationToken(token: someToken); + const String someToken = 'someToken'; + await plugin.clearAuthorizationToken( + const ClearAuthorizationTokensParams(accessToken: someToken), + ); final List arguments = mockito diff --git a/packages/google_sign_in/google_sign_in_web/example/integration_test/google_sign_in_web_test.mocks.dart b/packages/google_sign_in/google_sign_in_web/example/integration_test/google_sign_in_web_test.mocks.dart index cf152b6e0c8..ccd87c6e17f 100644 --- a/packages/google_sign_in/google_sign_in_web/example/integration_test/google_sign_in_web_test.mocks.dart +++ b/packages/google_sign_in/google_sign_in_web/example/integration_test/google_sign_in_web_test.mocks.dart @@ -1,4 +1,4 @@ -// Mocks generated by Mockito 5.4.5 from annotations +// Mocks generated by Mockito 5.4.6 from annotations // in google_sign_in_web_integration_tests/integration_test/google_sign_in_web_test.dart. // Do not manually edit this file. @@ -76,6 +76,12 @@ class MockGisSdkClient extends _i1.Mock implements _i2.GisSdkClient { ) as _i3.Future); + @override + void clearAuthorizationToken(String? token) => super.noSuchMethod( + Invocation.method(#clearAuthorizationToken, [token]), + returnValueForMissingStub: null, + ); + @override _i3.Future requestScopes( List? scopes, { diff --git a/packages/google_sign_in/google_sign_in_web/example/integration_test/web_only_test.mocks.dart b/packages/google_sign_in/google_sign_in_web/example/integration_test/web_only_test.mocks.dart index 057cc55d480..97a7fa91513 100644 --- a/packages/google_sign_in/google_sign_in_web/example/integration_test/web_only_test.mocks.dart +++ b/packages/google_sign_in/google_sign_in_web/example/integration_test/web_only_test.mocks.dart @@ -1,4 +1,4 @@ -// Mocks generated by Mockito 5.4.5 from annotations +// Mocks generated by Mockito 5.4.6 from annotations // in google_sign_in_web_integration_tests/integration_test/web_only_test.dart. // Do not manually edit this file. @@ -76,6 +76,12 @@ class MockGisSdkClient extends _i1.Mock implements _i2.GisSdkClient { ) as _i3.Future); + @override + void clearAuthorizationToken(String? token) => super.noSuchMethod( + Invocation.method(#clearAuthorizationToken, [token]), + returnValueForMissingStub: null, + ); + @override _i3.Future requestScopes( List? scopes, { diff --git a/packages/google_sign_in/google_sign_in_web/lib/google_sign_in_web.dart b/packages/google_sign_in/google_sign_in_web/lib/google_sign_in_web.dart index e71185365b9..b4e4dfeddcc 100644 --- a/packages/google_sign_in/google_sign_in_web/lib/google_sign_in_web.dart +++ b/packages/google_sign_in/google_sign_in_web/lib/google_sign_in_web.dart @@ -244,9 +244,11 @@ class GoogleSignInPlugin extends GoogleSignInPlatform { } @override - Future clearAuthorizationToken({required String token}) async { + Future clearAuthorizationToken( + ClearAuthorizationTokensParams params, + ) async { await initialized; - return _gisClient.clearAuthorizationToken(token); + return _gisClient.clearAuthorizationToken(params.accessToken); } @override diff --git a/packages/google_sign_in/google_sign_in_web/lib/src/gis_client.dart b/packages/google_sign_in/google_sign_in_web/lib/src/gis_client.dart index 0132bc2e7ad..6aa41b6a5c3 100644 --- a/packages/google_sign_in/google_sign_in_web/lib/src/gis_client.dart +++ b/packages/google_sign_in/google_sign_in_web/lib/src/gis_client.dart @@ -283,7 +283,7 @@ class GisSdkClient { void clearAuthorizationToken(String token) { _lastClientAuthorizationByUser.removeWhere( (String? key, (TokenResponse tokenResponse, DateTime expiration) value) => - value.tokenResponse.access_token == token, + value.$1.access_token == token, ); } From 1218b97fec0b6144870d186de66398067d028681 Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Mon, 18 Aug 2025 10:56:05 -0400 Subject: [PATCH 09/18] Add app-facing package test --- .../test/google_sign_in_test.dart | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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 b5c29a54c74..aa1cc8a5a20 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 @@ -760,4 +760,22 @@ void main() { ); }); }); + + group('clearAuthorizationToken', () { + test('passes expected paramaters', () async { + final GoogleSignIn googleSignIn = GoogleSignIn.instance; + + const String token = 'someAccessToken'; + await googleSignIn.authorizationClient.clearAuthorizationToken( + accessToken: token, + ); + + final VerificationResult verification = verify( + mockPlatform.clearAuthorizationToken(captureAny), + ); + final ClearAuthorizationTokensParams params = + verification.captured[0] as ClearAuthorizationTokensParams; + expect(params.accessToken, token); + }); + }); } From 3101fb3d3e732d42a21123c76f3be7c082ab3d1f Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Mon, 18 Aug 2025 11:52:53 -0400 Subject: [PATCH 10/18] Fix Android --- .../google_sign_in_android/android/build.gradle | 2 +- .../googlesignin/GoogleSignInPlugin.java | 9 +++++---- .../flutter/plugins/googlesignin/ResultUtils.kt | 4 ++-- .../plugins/googlesignin/GoogleSignInTest.java | 17 +++++++++++++---- 4 files changed, 21 insertions(+), 11 deletions(-) diff --git a/packages/google_sign_in/google_sign_in_android/android/build.gradle b/packages/google_sign_in/google_sign_in_android/android/build.gradle index 829160c5e0e..6be28fca14f 100644 --- a/packages/google_sign_in/google_sign_in_android/android/build.gradle +++ b/packages/google_sign_in/google_sign_in_android/android/build.gradle @@ -70,7 +70,7 @@ dependencies { implementation 'androidx.credentials:credentials:1.5.0' implementation 'androidx.credentials:credentials-play-services-auth:1.5.0' implementation 'com.google.android.libraries.identity.googleid:googleid:1.1.1' - implementation 'com.google.android.gms:play-services-auth:21.3.0' + implementation 'com.google.android.gms:play-services-auth:21.4.0' testImplementation 'junit:junit:4.13.2' testImplementation 'org.mockito:mockito-inline:5.2.0' } diff --git a/packages/google_sign_in/google_sign_in_android/android/src/main/java/io/flutter/plugins/googlesignin/GoogleSignInPlugin.java b/packages/google_sign_in/google_sign_in_android/android/src/main/java/io/flutter/plugins/googlesignin/GoogleSignInPlugin.java index bca07948228..128f4383321 100644 --- a/packages/google_sign_in/google_sign_in_android/android/src/main/java/io/flutter/plugins/googlesignin/GoogleSignInPlugin.java +++ b/packages/google_sign_in/google_sign_in_android/android/src/main/java/io/flutter/plugins/googlesignin/GoogleSignInPlugin.java @@ -32,6 +32,7 @@ import com.google.android.gms.auth.api.identity.AuthorizationClient; import com.google.android.gms.auth.api.identity.AuthorizationRequest; import com.google.android.gms.auth.api.identity.AuthorizationResult; +import com.google.android.gms.auth.api.identity.ClearTokenRequest; import com.google.android.gms.auth.api.identity.Identity; import com.google.android.gms.common.api.ApiException; import com.google.android.gms.common.api.Scope; @@ -331,12 +332,12 @@ public void clearCredentialState(@NonNull Function1, Unit> new CredentialManagerCallback<>() { @Override public void onResult(Void result) { - ResultUtilsKt.completeWithClearCredentialStateSuccess(callback); + ResultUtilsKt.completeWithUnitSuccess(callback); } @Override public void onError(@NonNull ClearCredentialException e) { - ResultUtilsKt.completeWithClearCredentialStateError( + ResultUtilsKt.completeWithUnitError( callback, new FlutterError("Clear Failed", e.getMessage(), null)); } }); @@ -347,14 +348,14 @@ public void clearAuthorizationToken( @NonNull String token, @NonNull Function1, Unit> callback) { authorizationClientFactory .create(context) - .clearToken(token) + .clearToken(ClearTokenRequest.builder().setToken(token).build()) .addOnSuccessListener( (Void) -> { ResultUtilsKt.completeWithUnitSuccess(callback); }) .addOnFailureListener( (Exception e) -> { - ResultUtilsKt.completeWithFlutterError( + ResultUtilsKt.completeWithUnitError( callback, new FlutterError("clearAuthorizationToken failed", e.getMessage(), null)); }); diff --git a/packages/google_sign_in/google_sign_in_android/android/src/main/kotlin/io/flutter/plugins/googlesignin/ResultUtils.kt b/packages/google_sign_in/google_sign_in_android/android/src/main/kotlin/io/flutter/plugins/googlesignin/ResultUtils.kt index 4a9f09795f7..820e4ee6c5c 100644 --- a/packages/google_sign_in/google_sign_in_android/android/src/main/kotlin/io/flutter/plugins/googlesignin/ResultUtils.kt +++ b/packages/google_sign_in/google_sign_in_android/android/src/main/kotlin/io/flutter/plugins/googlesignin/ResultUtils.kt @@ -18,11 +18,11 @@ fun completeWithGetCredentialFailure( callback(Result.success(failure)) } -fun completeWithClearCredentialStateSuccess(callback: (Result) -> Unit) { +fun completeWithUnitSuccess(callback: (Result) -> Unit) { callback(Result.success(Unit)) } -fun completeWithClearCredentialStateError(callback: (Result) -> Unit, failure: FlutterError) { +fun completeWithUnitError(callback: (Result) -> Unit, failure: FlutterError) { callback(Result.failure(failure)) } diff --git a/packages/google_sign_in/google_sign_in_android/android/src/test/java/io/flutter/plugins/googlesignin/GoogleSignInTest.java b/packages/google_sign_in/google_sign_in_android/android/src/test/java/io/flutter/plugins/googlesignin/GoogleSignInTest.java index 869fcdd39a7..77a0b2a4df0 100644 --- a/packages/google_sign_in/google_sign_in_android/android/src/test/java/io/flutter/plugins/googlesignin/GoogleSignInTest.java +++ b/packages/google_sign_in/google_sign_in_android/android/src/test/java/io/flutter/plugins/googlesignin/GoogleSignInTest.java @@ -40,6 +40,7 @@ import com.google.android.gms.auth.api.identity.AuthorizationClient; import com.google.android.gms.auth.api.identity.AuthorizationRequest; import com.google.android.gms.auth.api.identity.AuthorizationResult; +import com.google.android.gms.auth.api.identity.ClearTokenRequest; import com.google.android.gms.common.api.ApiException; import com.google.android.gms.common.api.Status; import com.google.android.gms.tasks.OnSuccessListener; @@ -71,6 +72,7 @@ public class GoogleSignInTest { @Mock CustomCredential mockGenericCredential; @Mock GoogleIdTokenCredential mockGoogleCredential; @Mock Task mockAuthorizationTask; + @Mock Task mockClearTokenTask; private GoogleSignInPlugin flutterPlugin; // Technically this is not the plugin, but in practice almost all of the functionality is in this @@ -88,6 +90,8 @@ public void setUp() { .thenReturn(GoogleIdTokenCredential.TYPE_GOOGLE_ID_TOKEN_CREDENTIAL); when(mockAuthorizationTask.addOnSuccessListener(any())).thenReturn(mockAuthorizationTask); when(mockAuthorizationTask.addOnFailureListener(any())).thenReturn(mockAuthorizationTask); + when(mockClearTokenTask.addOnSuccessListener(any())).thenReturn(mockClearTokenTask); + when(mockClearTokenTask.addOnFailureListener(any())).thenReturn(mockClearTokenTask); when(mockAuthorizationIntent.getIntentSender()).thenReturn(mockAuthorizationIntentSender); when(mockActivityPluginBinding.getActivity()).thenReturn(mockActivity); @@ -1100,10 +1104,10 @@ public void clearCredentialState_reportsFailure() { @Test public void clearAuthorizationToken_callsClient() { - final Task mockTask = mock(Task.class); - when(mockAuthorizationClient.clearToken(any())).thenReturn(mockTask); + final String testToken = "testToken"; + when(mockAuthorizationClient.clearToken(any())).thenReturn(mockClearTokenTask); plugin.clearAuthorizationToken( - "test_token", + testToken, ResultCompat.asCompatCallback( reply -> { // This test doesn't trigger the getCredentialsAsync callback that would call this, @@ -1112,6 +1116,11 @@ public void clearAuthorizationToken_callsClient() { return null; })); - verify(mockAuthorizationClient).clearToken("test_token"); + ArgumentCaptor authRequestCaptor = + ArgumentCaptor.forClass(ClearTokenRequest.class); + verify(mockAuthorizationClient).clearToken(authRequestCaptor.capture()); + + ClearTokenRequest request = authRequestCaptor.getValue(); + assertEquals(testToken, request.getToken()); } } From cc2695880210067e9f6669d94787bc21ded00943 Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Mon, 18 Aug 2025 13:54:43 -0400 Subject: [PATCH 11/18] Revert extension package changes --- .../example/pubspec.yaml | 4 ---- .../extension_google_sign_in_as_googleapis_auth/pubspec.yaml | 4 ---- 2 files changed, 8 deletions(-) diff --git a/packages/extension_google_sign_in_as_googleapis_auth/example/pubspec.yaml b/packages/extension_google_sign_in_as_googleapis_auth/example/pubspec.yaml index 7c4c667f1d8..8a297916798 100644 --- a/packages/extension_google_sign_in_as_googleapis_auth/example/pubspec.yaml +++ b/packages/extension_google_sign_in_as_googleapis_auth/example/pubspec.yaml @@ -26,7 +26,3 @@ dev_dependencies: flutter: uses-material-design: true -# FOR TESTING AND INITIAL REVIEW ONLY. DO NOT MERGE. -# See https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins -dependency_overrides: - google_sign_in: {path: ../../../packages/google_sign_in/google_sign_in} diff --git a/packages/extension_google_sign_in_as_googleapis_auth/pubspec.yaml b/packages/extension_google_sign_in_as_googleapis_auth/pubspec.yaml index eef00e770d2..c36b2a630e2 100644 --- a/packages/extension_google_sign_in_as_googleapis_auth/pubspec.yaml +++ b/packages/extension_google_sign_in_as_googleapis_auth/pubspec.yaml @@ -32,7 +32,3 @@ topics: false_secrets: - example/android/app/google-services.json -# FOR TESTING AND INITIAL REVIEW ONLY. DO NOT MERGE. -# See https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins -dependency_overrides: - google_sign_in: {path: ../../packages/google_sign_in/google_sign_in} From beb5dd5cdd0a49f4020d8354966e2d533781b2b3 Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Mon, 18 Aug 2025 13:59:00 -0400 Subject: [PATCH 12/18] Platform interface sanity test --- .../google_sign_in_platform_interface_test.dart | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/packages/google_sign_in/google_sign_in_platform_interface/test/google_sign_in_platform_interface_test.dart b/packages/google_sign_in/google_sign_in_platform_interface/test/google_sign_in_platform_interface_test.dart index 81caacd7108..099befd50c7 100644 --- a/packages/google_sign_in/google_sign_in_platform_interface/test/google_sign_in_platform_interface_test.dart +++ b/packages/google_sign_in/google_sign_in_platform_interface/test/google_sign_in_platform_interface_test.dart @@ -37,6 +37,21 @@ void main() { // this behavior, which could be implemented in the subclass. expect(ExtendsGoogleSignInPlatform().authenticationEvents, null); }); + + test( + 'Default implementation of clearAuthorizationToken throws unimplemented error', + () { + final ExtendsGoogleSignInPlatform platform = + ExtendsGoogleSignInPlatform(); + + expect( + () => platform.clearAuthorizationToken( + const ClearAuthorizationTokensParams(accessToken: 'someToken'), + ), + throwsUnimplementedError, + ); + }, + ); }); group('GoogleSignInUserData', () { From c7aefe725f5c94790375dd9ec601ef38b4393eea Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Mon, 18 Aug 2025 14:26:03 -0400 Subject: [PATCH 13/18] Simpler lambdas --- .../plugins/googlesignin/GoogleSignInPlugin.java | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/packages/google_sign_in/google_sign_in_android/android/src/main/java/io/flutter/plugins/googlesignin/GoogleSignInPlugin.java b/packages/google_sign_in/google_sign_in_android/android/src/main/java/io/flutter/plugins/googlesignin/GoogleSignInPlugin.java index 128f4383321..6cca2b98a73 100644 --- a/packages/google_sign_in/google_sign_in_android/android/src/main/java/io/flutter/plugins/googlesignin/GoogleSignInPlugin.java +++ b/packages/google_sign_in/google_sign_in_android/android/src/main/java/io/flutter/plugins/googlesignin/GoogleSignInPlugin.java @@ -220,7 +220,7 @@ public void getCredential( return; } - // getCredentialAsync requires an acitivity context, not an application context, per + // getCredentialAsync requires an activity context, not an application context, per // the API docs. Activity activity = getActivity(); if (activity == null) { @@ -349,16 +349,12 @@ public void clearAuthorizationToken( authorizationClientFactory .create(context) .clearToken(ClearTokenRequest.builder().setToken(token).build()) - .addOnSuccessListener( - (Void) -> { - ResultUtilsKt.completeWithUnitSuccess(callback); - }) + .addOnSuccessListener(unused -> ResultUtilsKt.completeWithUnitSuccess(callback)) .addOnFailureListener( - (Exception e) -> { - ResultUtilsKt.completeWithUnitError( - callback, - new FlutterError("clearAuthorizationToken failed", e.getMessage(), null)); - }); + e -> + ResultUtilsKt.completeWithUnitError( + callback, + new FlutterError("clearAuthorizationToken failed", e.getMessage(), null))); } @Override From d7d7b1ac4a927b2a674d61976353842a01ab0bb8 Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Mon, 18 Aug 2025 14:51:59 -0400 Subject: [PATCH 14/18] Improve Java test --- .../flutter/plugins/googlesignin/GoogleSignInTest.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/google_sign_in/google_sign_in_android/android/src/test/java/io/flutter/plugins/googlesignin/GoogleSignInTest.java b/packages/google_sign_in/google_sign_in_android/android/src/test/java/io/flutter/plugins/googlesignin/GoogleSignInTest.java index 77a0b2a4df0..665ca8d421f 100644 --- a/packages/google_sign_in/google_sign_in_android/android/src/test/java/io/flutter/plugins/googlesignin/GoogleSignInTest.java +++ b/packages/google_sign_in/google_sign_in_android/android/src/test/java/io/flutter/plugins/googlesignin/GoogleSignInTest.java @@ -1110,9 +1110,6 @@ public void clearAuthorizationToken_callsClient() { testToken, ResultCompat.asCompatCallback( reply -> { - // This test doesn't trigger the getCredentialsAsync callback that would call this, - // so if this is reached something has gone wrong. - fail(); return null; })); @@ -1120,6 +1117,12 @@ public void clearAuthorizationToken_callsClient() { ArgumentCaptor.forClass(ClearTokenRequest.class); verify(mockAuthorizationClient).clearToken(authRequestCaptor.capture()); + @SuppressWarnings("unchecked") + ArgumentCaptor> callbackCaptor = + ArgumentCaptor.forClass(OnSuccessListener.class); + verify(mockClearTokenTask).addOnSuccessListener(callbackCaptor.capture()); + callbackCaptor.getValue().onSuccess(null); + ClearTokenRequest request = authRequestCaptor.getValue(); assertEquals(testToken, request.getToken()); } From 0317ff24cad38fc3ff501123276bd824e47a7b49 Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Fri, 29 Aug 2025 12:59:03 -0400 Subject: [PATCH 15/18] Fix class pluralization --- .../google_sign_in/lib/google_sign_in.dart | 2 +- .../google_sign_in/test/google_sign_in_test.dart | 4 ++-- .../google_sign_in/test/google_sign_in_test.mocks.dart | 2 +- .../lib/google_sign_in_android.dart | 2 +- .../google_sign_in_ios/lib/google_sign_in_ios.dart | 2 +- .../test/google_sign_in_ios_test.dart | 2 +- .../lib/google_sign_in_platform_interface.dart | 4 ++-- .../lib/src/types.dart | 10 +++++----- .../test/google_sign_in_platform_interface_test.dart | 2 +- .../integration_test/google_sign_in_web_test.dart | 2 +- .../google_sign_in_web/lib/google_sign_in_web.dart | 2 +- 11 files changed, 17 insertions(+), 17 deletions(-) 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 3a1804cf242..3b00104756b 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 @@ -250,7 +250,7 @@ class GoogleSignInAuthorizationClient { /// https://support.google.com/accounts/answer/13533235. Future clearAuthorizationToken({required String accessToken}) { return GoogleSignInPlatform.instance.clearAuthorizationToken( - ClearAuthorizationTokensParams(accessToken: accessToken), + ClearAuthorizationTokenParams(accessToken: accessToken), ); } 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 aa1cc8a5a20..84670e53990 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 @@ -773,8 +773,8 @@ void main() { final VerificationResult verification = verify( mockPlatform.clearAuthorizationToken(captureAny), ); - final ClearAuthorizationTokensParams params = - verification.captured[0] as ClearAuthorizationTokensParams; + final ClearAuthorizationTokenParams params = + verification.captured[0] as ClearAuthorizationTokenParams; expect(params.accessToken, token); }); }); diff --git a/packages/google_sign_in/google_sign_in/test/google_sign_in_test.mocks.dart b/packages/google_sign_in/google_sign_in/test/google_sign_in_test.mocks.dart index e3e9d156b7e..24107898358 100644 --- a/packages/google_sign_in/google_sign_in/test/google_sign_in_test.mocks.dart +++ b/packages/google_sign_in/google_sign_in/test/google_sign_in_test.mocks.dart @@ -112,7 +112,7 @@ class MockGoogleSignInPlatform extends _i1.Mock @override _i4.Future clearAuthorizationToken( - _i2.ClearAuthorizationTokensParams? params, + _i2.ClearAuthorizationTokenParams? params, ) => (super.noSuchMethod( Invocation.method(#clearAuthorizationToken, [params]), diff --git a/packages/google_sign_in/google_sign_in_android/lib/google_sign_in_android.dart b/packages/google_sign_in/google_sign_in_android/lib/google_sign_in_android.dart index 9450d57b38e..81915a6cfe7 100644 --- a/packages/google_sign_in/google_sign_in_android/lib/google_sign_in_android.dart +++ b/packages/google_sign_in/google_sign_in_android/lib/google_sign_in_android.dart @@ -28,7 +28,7 @@ class GoogleSignInAndroid extends GoogleSignInPlatform { } @override - Future clearAuthorizationToken(ClearAuthorizationTokensParams params) { + Future clearAuthorizationToken(ClearAuthorizationTokenParams params) { return _hostApi.clearAuthorizationToken(params.accessToken); } diff --git a/packages/google_sign_in/google_sign_in_ios/lib/google_sign_in_ios.dart b/packages/google_sign_in/google_sign_in_ios/lib/google_sign_in_ios.dart index 4b850ee297a..ecc5df4b1cb 100644 --- a/packages/google_sign_in/google_sign_in_ios/lib/google_sign_in_ios.dart +++ b/packages/google_sign_in/google_sign_in_ios/lib/google_sign_in_ios.dart @@ -136,7 +136,7 @@ class GoogleSignInIOS extends GoogleSignInPlatform { @override Future clearAuthorizationToken( - ClearAuthorizationTokensParams params, + ClearAuthorizationTokenParams params, ) async { // No-op; the iOS SDK handles token invalidation internally. } diff --git a/packages/google_sign_in/google_sign_in_ios/test/google_sign_in_ios_test.dart b/packages/google_sign_in/google_sign_in_ios/test/google_sign_in_ios_test.dart index afde51bb03b..08580cb9115 100644 --- a/packages/google_sign_in/google_sign_in_ios/test/google_sign_in_ios_test.dart +++ b/packages/google_sign_in/google_sign_in_ios/test/google_sign_in_ios_test.dart @@ -1234,7 +1234,7 @@ void main() { test('clearAuthorizationToken no-ops without error', () async { await googleSignIn.clearAuthorizationToken( - const ClearAuthorizationTokensParams(accessToken: 'any token'), + const ClearAuthorizationTokenParams(accessToken: 'any token'), ); verifyZeroInteractions(mockApi); diff --git a/packages/google_sign_in/google_sign_in_platform_interface/lib/google_sign_in_platform_interface.dart b/packages/google_sign_in/google_sign_in_platform_interface/lib/google_sign_in_platform_interface.dart index ca4f36d81f9..e8802abecda 100644 --- a/packages/google_sign_in/google_sign_in_platform_interface/lib/google_sign_in_platform_interface.dart +++ b/packages/google_sign_in/google_sign_in_platform_interface/lib/google_sign_in_platform_interface.dart @@ -99,7 +99,7 @@ abstract class GoogleSignInPlatform extends PlatformInterface { ); /// Clears any token cache for the given access token. - Future clearAuthorizationToken(ClearAuthorizationTokensParams params) { + Future clearAuthorizationToken(ClearAuthorizationTokenParams params) { throw UnimplementedError( 'clearAuthorizationToken() has not been implemented.', ); @@ -176,7 +176,7 @@ class _PlaceholderImplementation extends GoogleSignInPlatform { } @override - Future clearAuthorizationToken(ClearAuthorizationTokensParams params) { + Future clearAuthorizationToken(ClearAuthorizationTokenParams params) { throw UnimplementedError(); } 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 e4565d4d7b8..a77a6bbab74 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 @@ -363,12 +363,12 @@ class AuthenticationResults { final AuthenticationTokenData authenticationTokens; } -/// Parameters for the clearAuthorizationTokens method. +/// Parameters for the clearAuthorizationToken method. @immutable -class ClearAuthorizationTokensParams { - /// Creates new parameters for clearAuthorizationTokens with the given +class ClearAuthorizationTokenParams { + /// Creates new parameters for clearAuthorizationToken with the given /// [accessToken] - const ClearAuthorizationTokensParams({required this.accessToken}); + const ClearAuthorizationTokenParams({required this.accessToken}); /// The OAuth2 access token to clear. final String accessToken; @@ -381,7 +381,7 @@ class ClearAuthorizationTokensParams { if (other.runtimeType != runtimeType) { return false; } - return other is ClearAuthorizationTokensParams && + return other is ClearAuthorizationTokenParams && other.accessToken == accessToken; } } diff --git a/packages/google_sign_in/google_sign_in_platform_interface/test/google_sign_in_platform_interface_test.dart b/packages/google_sign_in/google_sign_in_platform_interface/test/google_sign_in_platform_interface_test.dart index 099befd50c7..65b8930a135 100644 --- a/packages/google_sign_in/google_sign_in_platform_interface/test/google_sign_in_platform_interface_test.dart +++ b/packages/google_sign_in/google_sign_in_platform_interface/test/google_sign_in_platform_interface_test.dart @@ -46,7 +46,7 @@ void main() { expect( () => platform.clearAuthorizationToken( - const ClearAuthorizationTokensParams(accessToken: 'someToken'), + const ClearAuthorizationTokenParams(accessToken: 'someToken'), ), throwsUnimplementedError, ); diff --git a/packages/google_sign_in/google_sign_in_web/example/integration_test/google_sign_in_web_test.dart b/packages/google_sign_in/google_sign_in_web/example/integration_test/google_sign_in_web_test.dart index 0433872b95e..3dd858fbd0c 100644 --- a/packages/google_sign_in/google_sign_in_web/example/integration_test/google_sign_in_web_test.dart +++ b/packages/google_sign_in/google_sign_in_web/example/integration_test/google_sign_in_web_test.dart @@ -362,7 +362,7 @@ void main() { testWidgets('calls clearAuthorizationToken on GIS client', (_) async { const String someToken = 'someToken'; await plugin.clearAuthorizationToken( - const ClearAuthorizationTokensParams(accessToken: someToken), + const ClearAuthorizationTokenParams(accessToken: someToken), ); final List arguments = diff --git a/packages/google_sign_in/google_sign_in_web/lib/google_sign_in_web.dart b/packages/google_sign_in/google_sign_in_web/lib/google_sign_in_web.dart index b4e4dfeddcc..4a7037341af 100644 --- a/packages/google_sign_in/google_sign_in_web/lib/google_sign_in_web.dart +++ b/packages/google_sign_in/google_sign_in_web/lib/google_sign_in_web.dart @@ -245,7 +245,7 @@ class GoogleSignInPlugin extends GoogleSignInPlatform { @override Future clearAuthorizationToken( - ClearAuthorizationTokensParams params, + ClearAuthorizationTokenParams params, ) async { await initialized; return _gisClient.clearAuthorizationToken(params.accessToken); From 62e9b688f13a1af4f2ef514f088c3038335f9fce Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Tue, 9 Sep 2025 16:04:44 -0400 Subject: [PATCH 16/18] Update platform interface refs --- packages/google_sign_in/google_sign_in/example/pubspec.yaml | 1 - packages/google_sign_in/google_sign_in/pubspec.yaml | 3 +-- .../google_sign_in_android/example/pubspec.yaml | 6 +----- packages/google_sign_in/google_sign_in_android/pubspec.yaml | 6 +----- .../google_sign_in/google_sign_in_ios/example/pubspec.yaml | 6 +----- packages/google_sign_in/google_sign_in_ios/pubspec.yaml | 6 +----- .../google_sign_in/google_sign_in_web/example/pubspec.yaml | 6 +----- packages/google_sign_in/google_sign_in_web/pubspec.yaml | 6 +----- 8 files changed, 7 insertions(+), 33 deletions(-) diff --git a/packages/google_sign_in/google_sign_in/example/pubspec.yaml b/packages/google_sign_in/google_sign_in/example/pubspec.yaml index 430cf8de953..f0a34743203 100644 --- a/packages/google_sign_in/google_sign_in/example/pubspec.yaml +++ b/packages/google_sign_in/google_sign_in/example/pubspec.yaml @@ -33,5 +33,4 @@ flutter: dependency_overrides: google_sign_in_android: {path: ../../../../packages/google_sign_in/google_sign_in_android} google_sign_in_ios: {path: ../../../../packages/google_sign_in/google_sign_in_ios} - google_sign_in_platform_interface: {path: ../../../../packages/google_sign_in/google_sign_in_platform_interface} google_sign_in_web: {path: ../../../../packages/google_sign_in/google_sign_in_web} diff --git a/packages/google_sign_in/google_sign_in/pubspec.yaml b/packages/google_sign_in/google_sign_in/pubspec.yaml index 3434920c6ca..87bf28d84d1 100644 --- a/packages/google_sign_in/google_sign_in/pubspec.yaml +++ b/packages/google_sign_in/google_sign_in/pubspec.yaml @@ -26,7 +26,7 @@ dependencies: sdk: flutter google_sign_in_android: ^7.0.0 google_sign_in_ios: ^6.0.0 - google_sign_in_platform_interface: ^3.0.0 + google_sign_in_platform_interface: ^3.1.0 google_sign_in_web: ^1.0.0 dev_dependencies: @@ -53,5 +53,4 @@ false_secrets: dependency_overrides: google_sign_in_android: {path: ../../../packages/google_sign_in/google_sign_in_android} google_sign_in_ios: {path: ../../../packages/google_sign_in/google_sign_in_ios} - google_sign_in_platform_interface: {path: ../../../packages/google_sign_in/google_sign_in_platform_interface} google_sign_in_web: {path: ../../../packages/google_sign_in/google_sign_in_web} diff --git a/packages/google_sign_in/google_sign_in_android/example/pubspec.yaml b/packages/google_sign_in/google_sign_in_android/example/pubspec.yaml index aa304309af3..65ac709b16d 100644 --- a/packages/google_sign_in/google_sign_in_android/example/pubspec.yaml +++ b/packages/google_sign_in/google_sign_in_android/example/pubspec.yaml @@ -16,7 +16,7 @@ dependencies: # The example app is bundled with the plugin so we use a path dependency on # the parent directory to use the current plugin's version. path: ../ - google_sign_in_platform_interface: ^3.0.0 + google_sign_in_platform_interface: ^3.1.0 http: ">=0.13.0 <2.0.0" dev_dependencies: @@ -28,7 +28,3 @@ dev_dependencies: flutter: uses-material-design: true -# FOR TESTING AND INITIAL REVIEW ONLY. DO NOT MERGE. -# See https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins -dependency_overrides: - google_sign_in_platform_interface: {path: ../../../../packages/google_sign_in/google_sign_in_platform_interface} diff --git a/packages/google_sign_in/google_sign_in_android/pubspec.yaml b/packages/google_sign_in/google_sign_in_android/pubspec.yaml index 666329cf533..b1f229277a4 100644 --- a/packages/google_sign_in/google_sign_in_android/pubspec.yaml +++ b/packages/google_sign_in/google_sign_in_android/pubspec.yaml @@ -20,7 +20,7 @@ flutter: dependencies: flutter: sdk: flutter - google_sign_in_platform_interface: ^3.0.0 + google_sign_in_platform_interface: ^3.1.0 dev_dependencies: build_runner: ^2.3.0 @@ -37,7 +37,3 @@ topics: false_secrets: - /example/android/app/google-services.json - /example/lib/main.dart -# FOR TESTING AND INITIAL REVIEW ONLY. DO NOT MERGE. -# See https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins -dependency_overrides: - google_sign_in_platform_interface: {path: ../../../packages/google_sign_in/google_sign_in_platform_interface} diff --git a/packages/google_sign_in/google_sign_in_ios/example/pubspec.yaml b/packages/google_sign_in/google_sign_in_ios/example/pubspec.yaml index 1ab1feeea15..ad373837e5d 100644 --- a/packages/google_sign_in/google_sign_in_ios/example/pubspec.yaml +++ b/packages/google_sign_in/google_sign_in_ios/example/pubspec.yaml @@ -16,7 +16,7 @@ dependencies: # The example app is bundled with the plugin so we use a path dependency on # the parent directory to use the current plugin's version. path: ../ - google_sign_in_platform_interface: ^3.0.0 + google_sign_in_platform_interface: ^3.1.0 http: ">=0.13.0 <2.0.0" dev_dependencies: @@ -27,7 +27,3 @@ dev_dependencies: flutter: uses-material-design: true -# FOR TESTING AND INITIAL REVIEW ONLY. DO NOT MERGE. -# See https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins -dependency_overrides: - google_sign_in_platform_interface: {path: ../../../../packages/google_sign_in/google_sign_in_platform_interface} diff --git a/packages/google_sign_in/google_sign_in_ios/pubspec.yaml b/packages/google_sign_in/google_sign_in_ios/pubspec.yaml index 1433e356eb6..32740bf1a8e 100644 --- a/packages/google_sign_in/google_sign_in_ios/pubspec.yaml +++ b/packages/google_sign_in/google_sign_in_ios/pubspec.yaml @@ -24,7 +24,7 @@ flutter: dependencies: flutter: sdk: flutter - google_sign_in_platform_interface: ^3.0.0 + google_sign_in_platform_interface: ^3.1.0 dev_dependencies: build_runner: ^2.4.6 @@ -44,7 +44,3 @@ false_secrets: - /example/ios/Runner/Info.plist - /example/lib/main.dart - /example/macos/Runner/Info.plist -# FOR TESTING AND INITIAL REVIEW ONLY. DO NOT MERGE. -# See https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins -dependency_overrides: - google_sign_in_platform_interface: {path: ../../../packages/google_sign_in/google_sign_in_platform_interface} diff --git a/packages/google_sign_in/google_sign_in_web/example/pubspec.yaml b/packages/google_sign_in/google_sign_in_web/example/pubspec.yaml index c37d0001454..1309d4f5b62 100644 --- a/packages/google_sign_in/google_sign_in_web/example/pubspec.yaml +++ b/packages/google_sign_in/google_sign_in_web/example/pubspec.yaml @@ -10,7 +10,7 @@ dependencies: flutter: sdk: flutter google_identity_services_web: ^0.3.1 - google_sign_in_platform_interface: ^3.0.0 + google_sign_in_platform_interface: ^3.1.0 google_sign_in_web: path: ../ @@ -26,7 +26,3 @@ dev_dependencies: flutter: uses-material-design: true -# FOR TESTING AND INITIAL REVIEW ONLY. DO NOT MERGE. -# See https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins -dependency_overrides: - google_sign_in_platform_interface: {path: ../../../../packages/google_sign_in/google_sign_in_platform_interface} diff --git a/packages/google_sign_in/google_sign_in_web/pubspec.yaml b/packages/google_sign_in/google_sign_in_web/pubspec.yaml index 5700c7226f1..fb7536ced4b 100644 --- a/packages/google_sign_in/google_sign_in_web/pubspec.yaml +++ b/packages/google_sign_in/google_sign_in_web/pubspec.yaml @@ -23,7 +23,7 @@ dependencies: flutter_web_plugins: sdk: flutter google_identity_services_web: ^0.3.1 - google_sign_in_platform_interface: ^3.0.0 + google_sign_in_platform_interface: ^3.1.0 http: ">=0.13.0 <2.0.0" web: ">=0.5.1 <2.0.0" @@ -34,7 +34,3 @@ dev_dependencies: topics: - authentication - google-sign-in -# FOR TESTING AND INITIAL REVIEW ONLY. DO NOT MERGE. -# See https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins -dependency_overrides: - google_sign_in_platform_interface: {path: ../../../packages/google_sign_in/google_sign_in_platform_interface} From 0bebd2b06a548ba4ec9179b3fc709302806dc730 Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Tue, 9 Sep 2025 18:20:57 -0400 Subject: [PATCH 17/18] Update Pigeon generation --- .../main/kotlin/io/flutter/plugins/googlesignin/Messages.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/google_sign_in/google_sign_in_android/android/src/main/kotlin/io/flutter/plugins/googlesignin/Messages.kt b/packages/google_sign_in/google_sign_in_android/android/src/main/kotlin/io/flutter/plugins/googlesignin/Messages.kt index bf7069ca6e4..149c72e6f7b 100644 --- a/packages/google_sign_in/google_sign_in_android/android/src/main/kotlin/io/flutter/plugins/googlesignin/Messages.kt +++ b/packages/google_sign_in/google_sign_in_android/android/src/main/kotlin/io/flutter/plugins/googlesignin/Messages.kt @@ -707,9 +707,9 @@ interface GoogleSignInApi { api.clearAuthorizationToken(tokenArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(wrapError(error)) + reply.reply(MessagesPigeonUtils.wrapError(error)) } else { - reply.reply(wrapResult(null)) + reply.reply(MessagesPigeonUtils.wrapResult(null)) } } } From 5bc6f48caf7d44e2e3a9470792692d654775e633 Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Wed, 17 Sep 2025 13:41:54 -0400 Subject: [PATCH 18/18] Update deps --- .../google_sign_in/example/pubspec.yaml | 8 +------- packages/google_sign_in/google_sign_in/pubspec.yaml | 12 +++--------- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/packages/google_sign_in/google_sign_in/example/pubspec.yaml b/packages/google_sign_in/google_sign_in/example/pubspec.yaml index f0a34743203..51bf7520b75 100644 --- a/packages/google_sign_in/google_sign_in/example/pubspec.yaml +++ b/packages/google_sign_in/google_sign_in/example/pubspec.yaml @@ -16,7 +16,7 @@ dependencies: # The example app is bundled with the plugin so we use a path dependency on # the parent directory to use the current plugin's version. path: ../ - google_sign_in_web: ^1.0.0 + google_sign_in_web: ^1.1.0 http: ">=0.13.0 <2.0.0" dev_dependencies: @@ -28,9 +28,3 @@ dev_dependencies: flutter: uses-material-design: true -# FOR TESTING AND INITIAL REVIEW ONLY. DO NOT MERGE. -# See https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins -dependency_overrides: - google_sign_in_android: {path: ../../../../packages/google_sign_in/google_sign_in_android} - google_sign_in_ios: {path: ../../../../packages/google_sign_in/google_sign_in_ios} - google_sign_in_web: {path: ../../../../packages/google_sign_in/google_sign_in_web} diff --git a/packages/google_sign_in/google_sign_in/pubspec.yaml b/packages/google_sign_in/google_sign_in/pubspec.yaml index 87bf28d84d1..56283530e42 100644 --- a/packages/google_sign_in/google_sign_in/pubspec.yaml +++ b/packages/google_sign_in/google_sign_in/pubspec.yaml @@ -24,10 +24,10 @@ flutter: dependencies: flutter: sdk: flutter - google_sign_in_android: ^7.0.0 - google_sign_in_ios: ^6.0.0 + google_sign_in_android: ^7.1.0 + google_sign_in_ios: ^6.2.0 google_sign_in_platform_interface: ^3.1.0 - google_sign_in_web: ^1.0.0 + google_sign_in_web: ^1.1.0 dev_dependencies: build_runner: ^2.1.10 @@ -48,9 +48,3 @@ false_secrets: - /example/ios/RunnerTests/GoogleService-Info.plist - /example/ios/RunnerTests/GoogleSignInTests.m - /example/macos/Runner/Info.plist -# FOR TESTING AND INITIAL REVIEW ONLY. DO NOT MERGE. -# See https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins -dependency_overrides: - google_sign_in_android: {path: ../../../packages/google_sign_in/google_sign_in_android} - google_sign_in_ios: {path: ../../../packages/google_sign_in/google_sign_in_ios} - google_sign_in_web: {path: ../../../packages/google_sign_in/google_sign_in_web}