21 lines
598 B
Dart
21 lines
598 B
Dart
import 'package:firebase_auth/firebase_auth.dart';
|
|
import 'package:google_sign_in/google_sign_in.dart';
|
|
|
|
class AuthService {
|
|
//Google Sign In
|
|
Future<User?> signInWithGoogle() async {
|
|
final GoogleSignInAccount? gUser = await GoogleSignIn().signIn();
|
|
final GoogleSignInAuthentication gAuth = await gUser!.authentication;
|
|
|
|
final credential = GoogleAuthProvider.credential(
|
|
accessToken: gAuth.accessToken,
|
|
idToken: gAuth.idToken,
|
|
);
|
|
|
|
final userCredential =
|
|
await FirebaseAuth.instance.signInWithCredential(credential);
|
|
|
|
return userCredential.user;
|
|
}
|
|
}
|