I have integrated firebase/google log in and I am now trying to integrate Facebook log in. I have set up my app so that I can log into Facebook successfully and retrieve my access token however, when I pass this to FirebaseAuth signInWithCredential I get the following output:
credential === AuthCredential(providerId: facebook.com, signInMethod: facebook.com, token: null)
I'm not sure why it is not being passed, this is where the code gets stuck. Here is my code for creating the Facebook Sign In feature:
Future<String> signInUserWithFacebook() async {
String returnValue = "error";
print('starting Facebook login');
final FacebookLogin fb = new FacebookLogin();
OurUser _user = OurUser();
final res = await fb.logIn(permissions:[
FacebookPermission.publicProfile,
FacebookPermission.email
]);
switch (res.status) {
case FacebookLoginStatus.success:
final FacebookAccessToken fbToken = res.accessToken;
print('Result status is success');
//Convert to Auth Credential
final AuthCredential credential =
FacebookAuthProvider.credential(fbToken.token);
print('token === ' + res.accessToken.token.toString());
print('credential === ' + credential.toString());
//User Credential to Sign in with Firebase
final result = await _auth.signInWithCredential(credential);
print('results === ' + result.toString());
_user.uid = result.user.uid;
_user.email = result.user.email;
_user.fullName = result.user.displayName;
OurDatabase().createUser(_user);
await OurDatabase().getUserInfo(result.user.uid);
if (_currentUser != null) {
returnValue = "success";
}
break;
case FacebookLoginStatus.cancel:
print('Login cancelled by the user.');
break;
case FacebookLoginStatus.error:
print('Something went wrong with the login process.');
break;
}
return returnValue;
}
Can anyone help me?
question from:
https://stackoverflow.com/questions/65918613/flutter-firebase-flutter-login-facebook-sucessfuly-retrieving-token-but-it-app 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…