我在 Flutter 中使用谷歌日历 API 和谷歌登录,但是当我尝试登录时,谷歌每次都想选择 Gmail 地址。
当我在没有谷歌日历 API 的情况下使用谷歌登录时,我的应用在第一次登录后自动登录。然后我添加了谷歌日历 API,谷歌开始希望我每次都选择一个 Gmail 帐户。
如何为 google API 选择 Google 登录帐户?
有代码。
final GoogleSignIn googleSignIn = GoogleSignIn(
clientId:"THIS IS CLIENT ID"
scopes: [
'https://www.googleapis.com/auth/calendar',
],
);
clientViaUserConsent(ClientId(googleSignIn.clientId, ''),
[CalendarApi.CalendarScope], prompt)
.then((AuthClient client) {
Constants.baseCl = client;
});
void prompt(String url) async {
if (await canLaunch(url)) {
await launch(url);
} else {
throw 'Could not launch $url';
}
}