How to add scopes to googleSignIn using Flutter

1.5k Views Asked by At

I'm having trouble using googleSignIn in Flutter, but only if I want to pass in scopes. Specifically, I'm trying to access Google's Healthcare API. I have a class that looks like this:

class GcsClient extends GoogleSignIn {
  GcsClient({this.baseUrl, List<String> scopes, String clientId})
      : super(clientId: clientId, scopes: scopes);

  final FhirUri baseUrl;

  Future access() async {
    final GoogleSignIn googleSignIn = GoogleSignIn();
    try {
      final account = await googleSignIn.signIn();
    } catch (e) {
      print(e);
    }
  }
}

When I call the access() method I sign in with no problem. Then I add the clientId (android app registered on google cloud, and user with access to the healthcare api specified), with some basic scopes, so signIn now looks like this:

final GoogleSignIn googleSignIn = GoogleSignIn(
      clientId:
          'myclientid-somealphanumericstring.apps.googleusercontent.com',
      scopes: ['profile', 'email']);

I again signin with no problems, although I can't access the Healthcare API. Next step is to add the scopes. I've tried both 'https://www.googleapis.com/auth/cloud-platform' and https://www.googleapis.com/auth/cloud-healthcare and the two together. So signin is now:

    final GoogleSignIn googleSignIn = GoogleSignIn(
      clientId:
           'myclientid-somealphanumericstring.apps.googleusercontent.com',
      scopes: [
        'profile',
        'email',
        'https://www.googleapis.com/auth/cloud-platform',
        'https://www.googleapis.com/auth/cloud-healthcare',
      ],
    );

But now when I run my app, it pulls up the login, I enter my user's information, and then it hangs. I get stuck with a white popup and the circular progress indicator going round and round but never responds. I'm happy to provide anymore information that might be helpful. Anyone have any idea what's going on?

1

There are 1 best solutions below

0
On

Your app may still be unverified and hence you would need to explicitly add the email as an email id you are using for your testing. Once you add it as a test user under Oauth Consent screen, this blank white screen with loader should go away.