Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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
Rename new method
  • Loading branch information
stuartmorgan-g committed Aug 18, 2025
commit 9e47e90c5321904368658a100b0df0e4e90e43fe
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> clearAuthCache({required String token}) {
return GoogleSignInPlatform.instance.clearAuthCache(token: token);
Future<void> clearAuthorizationToken({required String token}) {
return GoogleSignInPlatform.instance.clearAuthorizationToken(token: token);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,9 @@ class MockGoogleSignInPlatform extends _i1.Mock
as _i4.Future<void>);

@override
_i4.Future<void> clearAuthCache({required String? token}) =>
_i4.Future<void> clearAuthorizationToken({required String? token}) =>
(super.noSuchMethod(
Invocation.method(#clearAuthCache, [], {#token: token}),
Invocation.method(#clearAuthorizationToken, [], {#token: token}),
returnValue: _i4.Future<void>.value(),
returnValueForMissingStub: _i4.Future<void>.value(),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ public void onError(@NonNull ClearCredentialException e) {
}

@Override
public void clearAuthCache(
public void clearAuthorizationToken(
@NonNull String token, @NonNull Function1<? super Result<Unit>, Unit> callback) {
authorizationClientFactory
.create(context)
Expand All @@ -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));
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ interface GoogleSignInApi {
/** Clears CredentialManager credential state. */
fun clearCredentialState(callback: (Result<Unit>) -> Unit)
/** Clears the authorization cache for the given token. */
fun clearAuthCache(token: String, callback: (Result<Unit>) -> Unit)
fun clearAuthorizationToken(token: String, callback: (Result<Unit>) -> Unit)
/** Requests authorization tokens via AuthorizationClient. */
fun authorize(
params: PlatformAuthorizationRequest,
Expand Down Expand Up @@ -569,13 +569,13 @@ interface GoogleSignInApi {
val channel =
BasicMessageChannel<Any?>(
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<Any?>
val tokenArg = args[0] as String
api.clearAuthCache(tokenArg) { result: Result<Unit> ->
api.clearAuthorizationToken(tokenArg) { result: Result<Unit> ->
val error = result.exceptionOrNull()
if (error != null) {
reply.reply(wrapError(error))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1099,10 +1099,10 @@ public void clearCredentialState_reportsFailure() {
}

@Test
public void clearAuthCache_callsClient() {
public void clearAuthorizationToken_callsClient() {
final Task<Void> mockTask = mock(Task.class);
when(mockAuthorizationClient.clearToken(any())).thenReturn(mockTask);
plugin.clearAuthCache(
plugin.clearAuthorizationToken(
"test_token",
ResultCompat.asCompatCallback(
reply -> {
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> clearAuthCache({required String token}) {
return _hostApi.clearAuthCache(token);
Future<void> clearAuthorizationToken({required String token}) {
return _hostApi.clearAuthorizationToken(token);
}

@override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -526,9 +526,9 @@ class GoogleSignInApi {
}

/// Clears the authorization cache for the given token.
Future<void> clearAuthCache(String token) async {
Future<void> 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<Object?> pigeonVar_channel =
BasicMessageChannel<Object?>(
pigeonVar_channelName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ class MockGoogleSignInApi extends _i1.Mock implements _i2.GoogleSignInApi {
as _i4.Future<void>);

@override
_i4.Future<void> clearAuthCache(String? token) =>
_i4.Future<void> clearAuthorizationToken(String? token) =>
(super.noSuchMethod(
Invocation.method(#clearAuthCache, [token]),
Invocation.method(#clearAuthorizationToken, [token]),
returnValue: _i4.Future<void>.value(),
returnValueForMissingStub: _i4.Future<void>.value(),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,13 @@ abstract class GoogleSignInPlatform extends PlatformInterface {
/// them out.
Future<void> 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<void> clearAuthCache({required String token}) {
throw UnimplementedError('clearAuthCache() has not been implemented.');
Future<void> clearAuthorizationToken({required String token}) {
throw UnimplementedError(
'clearAuthorizationToken() has not been implemented.',
);
}

/// Returns a stream of authentication events.
Expand Down Expand Up @@ -186,7 +188,7 @@ class _PlaceholderImplementation extends GoogleSignInPlatform {
}

@override
Future<void> clearAuthCache({required String token}) {
Future<void> clearAuthorizationToken({required String token}) {
throw UnimplementedError();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<Object?> arguments =
mockito.verify(mockGis.clearAuthCache(mockito.captureAny)).captured;
mockito
.verify(mockGis.clearAuthorizationToken(mockito.captureAny))
.captured;

expect(arguments.first, someToken);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,9 @@ class GoogleSignInPlugin extends GoogleSignInPlatform {
}

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

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