Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Parameter object
  • Loading branch information
stuartmorgan-g committed Aug 18, 2025
commit 04d1cb83c1cecddab38c179d1d8596beaad89342
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ class GoogleSignInAuthorizationClient {
/// https://support.google.com/accounts/answer/13533235.
Future<void> clearAuthorizationToken({required String accessToken}) {
return GoogleSignInPlatform.instance.clearAuthorizationToken(
token: accessToken,
ClearAuthorizationTokensParams(accessToken: accessToken),
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,27 +111,29 @@ class MockGoogleSignInPlatform extends _i1.Mock
as _i4.Future<_i2.ServerAuthorizationTokenData?>);

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

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

@override
_i4.Future<void> clearAuthorizationToken({required String? token}) =>
_i4.Future<void> disconnect(_i2.DisconnectParams? params) =>
(super.noSuchMethod(
Invocation.method(#clearAuthorizationToken, [], {#token: token}),
Invocation.method(#disconnect, [params]),
returnValue: _i4.Future<void>.value(),
returnValueForMissingStub: _i4.Future<void>.value(),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ class GoogleSignInAndroid extends GoogleSignInPlatform {
}

@override
Future<void> clearAuthorizationToken({required String token}) {
return _hostApi.clearAuthorizationToken(token);
Future<void> clearAuthorizationToken(ClearAuthorizationTokensParams params) {
return _hostApi.clearAuthorizationToken(params.accessToken);
}

@override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,9 @@ class GoogleSignInIOS extends GoogleSignInPlatform {
}

@override
Future<void> clearAuthorizationToken({required String token}) async {
Future<void> clearAuthorizationToken(
ClearAuthorizationTokensParams params,
) async {
// No-op; the iOS SDK handles token invalidation internally.
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down
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_ios/test/google_sign_in_ios_test.dart.
// Do not manually edit this file.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,22 +98,20 @@ abstract class GoogleSignInPlatform extends PlatformInterface {
ServerAuthorizationTokensForScopesParameters params,
);

/// Clears any token cache for the given access token.
Future<void> clearAuthorizationToken(ClearAuthorizationTokensParams params) {
throw UnimplementedError(
'clearAuthorizationToken() has not been implemented.',
);
}

/// Signs out previously signed in accounts.
Future<void> signOut(SignOutParams params);

/// Revokes all of the scopes that all signed in users granted, and then signs
/// them out.
Future<void> disconnect(DisconnectParams params);

/// Clears the token cache for the given access token.
///
/// How this is implemented is up to the platform.
Future<void> 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
Expand Down Expand Up @@ -178,17 +176,17 @@ class _PlaceholderImplementation extends GoogleSignInPlatform {
}

@override
Future<void> signOut(SignOutParams params) {
Future<void> clearAuthorizationToken(ClearAuthorizationTokensParams params) {
throw UnimplementedError();
}

@override
Future<void> disconnect(DisconnectParams params) {
Future<void> signOut(SignOutParams params) {
throw UnimplementedError();
}

@override
Future<void> clearAuthorizationToken({required String token}) {
Future<void> disconnect(DisconnectParams params) {
throw UnimplementedError();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,29 @@ class AuthenticationResults {
final AuthenticationTokenData authenticationTokens;
}

/// Parameters for the clearAuthorizationTokens method.
@immutable
class ClearAuthorizationTokensParams {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: do we always need to introduce an additional type for parameters? Is it specifically for pigeon?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to mark the class final (so no need for the runtimeType check in ==), or using an extension type?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: do we always need to introduce an additional type for parameters?

We don't have to, but the alternative is creating a new method and doing a cumbersome deprecation+migration every time we want to add a parameter.

Is it specifically for pigeon?

No, it's unrelated to how platform implementations work.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to mark the class final (so no need for the runtimeType check in ==), or using an extension type?

We sometimes make platform-specific subclasses of parameter classes, so I would prefer not to make them final.

/// 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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Object?> arguments =
mockito
Expand Down
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_web_integration_tests/integration_test/google_sign_in_web_test.dart.
// Do not manually edit this file.

Expand Down Expand Up @@ -76,6 +76,12 @@ class MockGisSdkClient extends _i1.Mock implements _i2.GisSdkClient {
)
as _i3.Future<void>);

@override
void clearAuthorizationToken(String? token) => super.noSuchMethod(
Invocation.method(#clearAuthorizationToken, [token]),
returnValueForMissingStub: null,
);

@override
_i3.Future<String?> requestScopes(
List<String>? scopes, {
Expand Down
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_web_integration_tests/integration_test/web_only_test.dart.
// Do not manually edit this file.

Expand Down Expand Up @@ -76,6 +76,12 @@ class MockGisSdkClient extends _i1.Mock implements _i2.GisSdkClient {
)
as _i3.Future<void>);

@override
void clearAuthorizationToken(String? token) => super.noSuchMethod(
Invocation.method(#clearAuthorizationToken, [token]),
returnValueForMissingStub: null,
);

@override
_i3.Future<String?> requestScopes(
List<String>? scopes, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,11 @@ class GoogleSignInPlugin extends GoogleSignInPlatform {
}

@override
Future<void> clearAuthorizationToken({required String token}) async {
Future<void> clearAuthorizationToken(
ClearAuthorizationTokensParams params,
) async {
await initialized;
return _gisClient.clearAuthorizationToken(token);
return _gisClient.clearAuthorizationToken(params.accessToken);
}

@override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
}

Expand Down