1

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?

TJMitch95
  • 421
  • 3
  • 7
  • 23
  • Does this answer your question? [No Firebase App '\[DEFAULT\]' has been created - call Firebase.initializeApp() in Flutter and Firebase](https://stackoverflow.com/questions/63492211/no-firebase-app-default-has-been-created-call-firebase-initializeapp-in) –  Jan 27 '21 at 11:59
  • Sadly not, I have implemented the advise given in that post and firebase sign up and google sign up work fine, its just Facebook that's tripping me up – TJMitch95 Jan 27 '21 at 12:01
  • i am having this problem now, did you manage to solve this? – Gbenga B Ayannuga May 11 '21 at 21:00

0 Answers0