Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
b072fa1
feat(google_sign_in): add clearAuthCache API
google-labs-jules[bot] Aug 18, 2025
92adf68
Fix versioning
stuartmorgan-g Aug 18, 2025
9e47e90
Rename new method
stuartmorgan-g Aug 18, 2025
0666ee9
Move the app-facing method to the authorization client, and improve docs
stuartmorgan-g Aug 18, 2025
83be004
Update migration guide
stuartmorgan-g Aug 18, 2025
f8c5625
Add a no-op on iOS
stuartmorgan-g Aug 18, 2025
e4a08c6
Fix up path overrides
stuartmorgan-g Aug 18, 2025
04d1cb8
Parameter object
stuartmorgan-g Aug 18, 2025
1218b97
Add app-facing package test
stuartmorgan-g Aug 18, 2025
3101fb3
Fix Android
stuartmorgan-g Aug 18, 2025
cc26958
Revert extension package changes
stuartmorgan-g Aug 18, 2025
beb5dd5
Platform interface sanity test
stuartmorgan-g Aug 18, 2025
c7aefe7
Simpler lambdas
stuartmorgan-g Aug 18, 2025
d7d7b1a
Improve Java test
stuartmorgan-g Aug 18, 2025
4272d38
Merge branch 'main' into google-sign-in-add-clear-authorization
stuartmorgan-g Aug 29, 2025
0317ff2
Fix class pluralization
stuartmorgan-g Aug 29, 2025
7b81325
Merge branch 'main' into google-sign-in-add-clear-authorization
stuartmorgan-g Sep 9, 2025
62e9b68
Update platform interface refs
stuartmorgan-g Sep 9, 2025
0bebd2b
Update Pigeon generation
stuartmorgan-g Sep 9, 2025
c4a725e
Merge branch 'main' into google-sign-in-add-clear-authorization
stuartmorgan-g Sep 17, 2025
cb94fce
Merge branch 'main' into google-sign-in-add-clear-authorization
stuartmorgan-g Sep 17, 2025
5bc6f48
Update deps
stuartmorgan-g Sep 17, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/google_sign_in/google_sign_in/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## NEXT
## 7.2.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.

## 7.1.1
Expand Down
1 change: 1 addition & 0 deletions packages/google_sign_in/google_sign_in/MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
29 changes: 27 additions & 2 deletions packages/google_sign_in/google_sign_in/lib/google_sign_in.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<GoogleSignInClientAuthorization?> authorizationForScopes(
List<String> scopes,
) async {
Expand All @@ -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<GoogleSignInClientAuthorization> authorizeScopes(
List<String> scopes,
) async {
Expand All @@ -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<Map<String, String>?> authorizationHeaders(
Expand Down Expand Up @@ -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<GoogleSignInServerAuthorization?> authorizeServer(
List<String> scopes,
) async {
Expand All @@ -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<void> clearAuthorizationToken({required String accessToken}) {
return GoogleSignInPlatform.instance.clearAuthorizationToken(
ClearAuthorizationTokenParams(accessToken: accessToken),
);
}

Future<GoogleSignInClientAuthorization?> _authorizeClient(
List<String> scopes, {
required bool promptIfUnauthorized,
Expand Down
10 changes: 5 additions & 5 deletions packages/google_sign_in/google_sign_in/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.2.0

environment:
sdk: ^3.7.0
Expand All @@ -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_platform_interface: ^3.0.0
google_sign_in_web: ^1.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.1.0

dev_dependencies:
build_runner: ^2.1.10
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 ClearAuthorizationTokenParams params =
verification.captured[0] as ClearAuthorizationTokenParams;
expect(params.accessToken, token);
});
});
}
Original file line number Diff line number Diff line change
@@ -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.

Expand Down Expand Up @@ -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,
Expand All @@ -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(
Expand Down Expand Up @@ -110,6 +110,17 @@ class MockGoogleSignInPlatform extends _i1.Mock
)
as _i4.Future<_i2.ServerAuthorizationTokenData?>);

@override
_i4.Future<void> clearAuthorizationToken(
_i2.ClearAuthorizationTokenParams? params,
) =>
(super.noSuchMethod(
Invocation.method(#clearAuthorizationToken, [params]),
returnValue: _i4.Future<void>.value(),
returnValueForMissingStub: _i4.Future<void>.value(),
)
as _i4.Future<void>);

@override
_i4.Future<void> signOut(_i2.SignOutParams? params) =>
(super.noSuchMethod(
Expand Down