Finished Implementation of the google sign in provider and its tests, moved mock class definitions to the end of the file in all tests
This commit is contained in:
parent
d4e5228db1
commit
41cbe35ff1
1 changed files with 0 additions and 28 deletions
|
|
@ -1,28 +0,0 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:firebase_auth/firebase_auth.dart';
|
||||
import 'package:google_sign_in/google_sign_in.dart';
|
||||
|
||||
class GoogleSignInProvider {
|
||||
final GoogleSignIn _googleSignIn;
|
||||
final FirebaseAuth _auth;
|
||||
|
||||
GoogleSignInProvider([GoogleSignIn googleSignIn, FirebaseAuth firebaseAuth])
|
||||
: _googleSignIn = googleSignIn ?? GoogleSignIn(),
|
||||
_auth = firebaseAuth ?? FirebaseAuth.instance;
|
||||
|
||||
Future<FirebaseUser> signIn() async {
|
||||
final GoogleSignInAccount googleUser = await _googleSignIn.signIn();
|
||||
final GoogleSignInAuthentication googleAuth =
|
||||
await googleUser.authentication;
|
||||
|
||||
final AuthCredential credential = GoogleAuthProvider.getCredential(
|
||||
accessToken: googleAuth.accessToken,
|
||||
idToken: googleAuth.idToken,
|
||||
);
|
||||
|
||||
final FirebaseUser user = await _auth.signInWithCredential(credential);
|
||||
print("signed in " + user.displayName);
|
||||
return user;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue