thinkdigital

AndroidX Firebase/Google Auth

Mar 21st, 2019
26
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 0.87 KB | None | 0 0
  1.         final FirebaseAuth _auth = FirebaseAuth.instance;
  2.  
  3.         // GoogleSignIn is a specific sign in class.
  4.         final GoogleSignIn _googleSignIn = GoogleSignIn();
  5.  
  6.         // Try to sign in the user.
  7.         // This method will either log in a user that your Firebase
  8.         // is aware of, or it will prompt the user to log in
  9.         // if its the first time.
  10.         //
  11.         GoogleSignInAccount googleUser = await _googleSignIn.signIn();
  12.         GoogleSignInAuthentication googleAuth = await googleUser.authentication;
  13.         AuthCredential authCredential = GoogleAuthProvider.getCredential(
  14.             idToken: googleAuth.idToken, accessToken: googleAuth.accessToken);
  15.         // After checking for authentication,
  16.         // We wil actually sign in the user
  17.         // using the token that firebase.
  18.         user = await _auth.signInWithCredential(authCredential);
Add Comment
Please, Sign In to add comment