Skip to content

Instantly share code, notes, and snippets.

@DmitrySikorsky
Created December 23, 2022 20:02
Show Gist options
  • Save DmitrySikorsky/fd24ec849621170dae8c226143c1aca7 to your computer and use it in GitHub Desktop.
Save DmitrySikorsky/fd24ec849621170dae8c226143c1aca7 to your computer and use it in GitHub Desktop.
if (!kIsWeb && Platform.isAndroid) {
GoogleSignIn googleSignIn = GoogleSignIn(
scopes: <String>['email'],
);
try {
GoogleSignInAccount account = (await googleSignIn.signIn())!;
// Send the account.serverAuthCode to your server to exchange it for the token
await validateEmailWithGoogleAndLogin(account.serverAuthCode!);
// As we do not really use the sign in features of the plugin,
// we need to sign out the user after we get the email from the access token on the server,
// so next time the user signs out in the app,
// he won’t be silently signed in into the Google account and see the Google sign in page instead.
await googleSignIn.signOut();
} catch (e) {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment