mirror of
https://github.com/kuhyx/todo-app.git
synced 2026-11-10 19:07:02 +01:00
System account chooser plus getAuthToken with an audience:server:client_id token; no Google client library. Pins bumped to newest stable. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WzxdWY1k4muZfdVJfb7YGJ
28 lines
799 B
Dart
28 lines
799 B
Dart
import 'dart:developer';
|
|
|
|
import 'package:flutter/services.dart';
|
|
|
|
/// Talks to `AccountTokenChannel.kt`: system account chooser, then
|
|
/// AccountManager's `audience:server:client_id:` token. No browser.
|
|
const kAccountTokenChannel = MethodChannel('dev.kuhy.todo/account_token');
|
|
|
|
/// A Google ID token for [serverClientId], or null on cancel or failure.
|
|
Future<String?> accountManagerIdToken({
|
|
required String serverClientId,
|
|
MethodChannel channel = kAccountTokenChannel,
|
|
}) async {
|
|
try {
|
|
return await channel.invokeMethod<String>('idToken', {
|
|
'serverClientId': serverClientId,
|
|
});
|
|
} on PlatformException catch (error, stackTrace) {
|
|
log(
|
|
'AccountManager token failed',
|
|
level: 900,
|
|
error: error,
|
|
stackTrace: stackTrace,
|
|
);
|
|
return null;
|
|
}
|
|
}
|