Flutter ,Google apis wants choose gmail adress every time

495 Views Asked by At

I'm using google calender API and google sign-in in Flutter but when I try to log in, google wants to choose Gmail address every time.

When I was using google sign in without google calender API, my app was logging in automatically after the first login. Then I added google calender API and Google starts to wants me to choose a Gmail account every time.

How can I choose Google signed-in account for google API?

There is the code.


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';
    }
  }



0

There are 0 best solutions below