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 ea013bb543e..eabc8cbc2a1 100644 --- a/packages/google_sign_in/google_sign_in_android/CHANGELOG.md +++ b/packages/google_sign_in/google_sign_in_android/CHANGELOG.md @@ -1,3 +1,7 @@ +## 7.1.0 + +* Adds support for the `clearAuthorizationToken` method. + ## 7.0.5 * Adds support for `hostedDomain` when authenticating. 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 3a12a656595..7ea2f885914 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 b9410d737fd..72421037901 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; @@ -219,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) { @@ -337,17 +338,31 @@ 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)); } }); } + @Override + public void clearAuthorizationToken( + @NonNull String token, @NonNull Function1, Unit> callback) { + authorizationClientFactory + .create(context) + .clearToken(ClearTokenRequest.builder().setToken(token).build()) + .addOnSuccessListener(unused -> ResultUtilsKt.completeWithUnitSuccess(callback)) + .addOnFailureListener( + e -> + ResultUtilsKt.completeWithUnitError( + callback, + new FlutterError("clearAuthorizationToken failed", 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 91f61b3e15c..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 @@ -606,6 +606,8 @@ interface GoogleSignInApi { ) /** Clears CredentialManager credential state. */ fun clearCredentialState(callback: (Result) -> Unit) + /** Clears the authorization cache for the given token. */ + fun clearAuthorizationToken(token: String, callback: (Result) -> Unit) /** Requests authorization tokens via AuthorizationClient. */ fun authorize( params: PlatformAuthorizationRequest, @@ -692,6 +694,29 @@ interface GoogleSignInApi { channel.setMessageHandler(null) } } + run { + val channel = + BasicMessageChannel( + binaryMessenger, + "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.clearAuthorizationToken(tokenArg) { result: Result -> + val error = result.exceptionOrNull() + if (error != null) { + reply.reply(MessagesPigeonUtils.wrapError(error)) + } else { + reply.reply(MessagesPigeonUtils.wrapResult(null)) + } + } + } + } else { + channel.setMessageHandler(null) + } + } run { val channel = BasicMessageChannel( 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 5b17c765cbb..7fa058c367f 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); @@ -1144,4 +1148,29 @@ public void clearCredentialState_reportsFailure() { callbackCaptor.getValue().onError(mock(ClearCredentialException.class)); } + + @Test + public void clearAuthorizationToken_callsClient() { + final String testToken = "testToken"; + when(mockAuthorizationClient.clearToken(any())).thenReturn(mockClearTokenTask); + plugin.clearAuthorizationToken( + testToken, + ResultCompat.asCompatCallback( + reply -> { + return null; + })); + + ArgumentCaptor authRequestCaptor = + 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()); + } } 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..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: 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 15e8d39efdc..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 @@ -27,6 +27,11 @@ class GoogleSignInAndroid extends GoogleSignInPlatform { GoogleSignInPlatform.instance = GoogleSignInAndroid(); } + @override + Future clearAuthorizationToken(ClearAuthorizationTokenParams params) { + return _hostApi.clearAuthorizationToken(params.accessToken); + } + @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 dd84e296778..d23bbe6daa4 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 @@ -713,6 +713,34 @@ class GoogleSignInApi { } } + /// Clears the authorization cache for the given token. + Future clearAuthorizationToken(String token) async { + final String pigeonVar_channelName = + 'dev.flutter.pigeon.google_sign_in_android.GoogleSignInApi.clearAuthorizationToken$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 dc9267020ab..4b0f5b86fb7 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,6 +196,10 @@ abstract class GoogleSignInApi { @async void clearCredentialState(); + /// Clears the authorization cache for the given token. + @async + void clearAuthorizationToken(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 7d24cfcc335..b1f229277a4 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.5 +version: 7.1.0 environment: sdk: ^3.7.0 @@ -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 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..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 @@ -82,6 +82,15 @@ class MockGoogleSignInApi extends _i1.Mock implements _i2.GoogleSignInApi { ) as _i4.Future); + @override + _i4.Future clearAuthorizationToken(String? token) => + (super.noSuchMethod( + Invocation.method(#clearAuthorizationToken, [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/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/example/pubspec.yaml b/packages/google_sign_in/google_sign_in_ios/example/pubspec.yaml index bc12daff1c2..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: 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..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 @@ -134,6 +134,13 @@ class GoogleSignInIOS extends GoogleSignInPlatform { : ServerAuthorizationTokenData(serverAuthCode: serverAuthCode); } + @override + Future clearAuthorizationToken( + ClearAuthorizationTokenParams params, + ) 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/pubspec.yaml b/packages/google_sign_in/google_sign_in_ios/pubspec.yaml index eb0b202314f..32740bf1a8e 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 @@ -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 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..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 @@ -1232,6 +1232,14 @@ void main() { verifyInOrder(>[mockApi.disconnect(), mockApi.signOut()]); }); + test('clearAuthorizationToken no-ops without error', () async { + await googleSignIn.clearAuthorizationToken( + const ClearAuthorizationTokenParams(accessToken: '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 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_web/CHANGELOG.md b/packages/google_sign_in/google_sign_in_web/CHANGELOG.md index 86b1a053fd7..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,5 +1,6 @@ -## NEXT +## 1.1.0 +* 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/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..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 @@ -353,6 +353,26 @@ void main() { ); }); }); + + group('clearAuthorizationToken', () { + setUp(() { + plugin.init(options); + }); + + testWidgets('calls clearAuthorizationToken on GIS client', (_) async { + const String someToken = 'someToken'; + await plugin.clearAuthorizationToken( + const ClearAuthorizationTokenParams(accessToken: someToken), + ); + + final List arguments = + mockito + .verify(mockGis.clearAuthorizationToken(mockito.captureAny)) + .captured; + + expect(arguments.first, someToken); + }); + }); }); group('userDataEvents', () { 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/example/pubspec.yaml b/packages/google_sign_in/google_sign_in_web/example/pubspec.yaml index f01050554b5..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: ../ 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..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 @@ -243,6 +243,14 @@ class GoogleSignInPlugin extends GoogleSignInPlatform { ); } + @override + Future clearAuthorizationToken( + ClearAuthorizationTokenParams params, + ) async { + await initialized; + return _gisClient.clearAuthorizationToken(params.accessToken); + } + @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..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 @@ -279,6 +279,14 @@ class GisSdkClient { await signOut(); } + /// Clears the authorization cache for the given [token]. + void clearAuthorizationToken(String token) { + _lastClientAuthorizationByUser.removeWhere( + (String? key, (TokenResponse tokenResponse, DateTime expiration) value) => + value.$1.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..fb7536ced4b 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.1.0 environment: sdk: ^3.7.0 @@ -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"