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..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,5 +1,7 @@ -## NEXT +## 3.1.0 +* 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/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..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 @@ -98,6 +98,13 @@ abstract class GoogleSignInPlatform extends PlatformInterface { ServerAuthorizationTokensForScopesParameters params, ); + /// Clears any token cache for the given access token. + Future clearAuthorizationToken(ClearAuthorizationTokenParams params) { + throw UnimplementedError( + 'clearAuthorizationToken() has not been implemented.', + ); + } + /// Signs out previously signed in accounts. Future signOut(SignOutParams params); @@ -168,6 +175,11 @@ class _PlaceholderImplementation extends GoogleSignInPlatform { throw UnimplementedError(); } + @override + Future clearAuthorizationToken(ClearAuthorizationTokenParams params) { + throw UnimplementedError(); + } + @override Future signOut(SignOutParams 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..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,6 +363,29 @@ class AuthenticationResults { final AuthenticationTokenData authenticationTokens; } +/// Parameters for the clearAuthorizationToken method. +@immutable +class ClearAuthorizationTokenParams { + /// Creates new parameters for clearAuthorizationToken with the given + /// [accessToken] + const ClearAuthorizationTokenParams({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 ClearAuthorizationTokenParams && + other.accessToken == accessToken; + } +} + /// Parameters for the signOut method. @immutable class SignOutParams { 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..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.0 +version: 3.1.0 environment: sdk: ^3.7.0 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..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 @@ -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 ClearAuthorizationTokenParams(accessToken: 'someToken'), + ), + throwsUnimplementedError, + ); + }, + ); }); group('GoogleSignInUserData', () { diff --git a/script/tool/bin/flutter_plugin_tools.dart b/script/tool/bin/flutter_plugin_tools.dart old mode 100644 new mode 100755