googleSSO method

Future<Map<String, dynamic>> googleSSO(
  1. String token,
  2. String backend,
  3. String clientId,
  4. List<String> scopes,
  5. Map body,
)

Implementation

Future<Map<String, dynamic>> googleSSO(String token, String backend,
    String clientId, List<String> scopes, Map body) async {
  GoogleSignIn googleSignIn = GoogleSignIn(
    scopes: [
      'email',
    ],
  );
  if (kIsWeb || Platform.isAndroid) {
    googleSignIn = GoogleSignIn(
      scopes: [
        'email',
      ],
    );
  }
  if (Platform.isIOS || Platform.isMacOS) {
    googleSignIn = GoogleSignIn(
      clientId: clientId,
      scopes: [
        'email',
      ],
    );
  }
  GoogleSignInAccount? googleAccount;
  try {
    googleAccount = await googleSignIn.signIn().catchError((onError) => null);
  } catch (e) {
    // print(e);
  }

  if (googleAccount != null) {
    final GoogleSignInAuthentication googleAuthentication =
        await googleAccount.authentication;
    return {'token': googleAuthentication.accessToken};
  }
  return {"token": "", "success": false};
}