Saturday, July 16, 2022

[FIXED] How can I create a facebook login page with firebase in flutter if "SignInWithFacebook" is not available anymore?

Issue

I'm trying to have a facebook login page but everywhere I see they use signInWithFacebook, unfortunately it seems they've modified it and it's not available anymore, what should I do instead? Thanks for your help!

class _AuthScreenState extends State<AuthScreen> {


FirebaseAuth _auth = FirebaseAuth.instance;

bool isLogged = false;

Future<FirebaseUser> _loginWithFacebook() async {
 var facebookLogin = new FacebookLogin();
 var result = await 
  facebookLogin.logInWithReadPermissions(["email"]);

  debugPrint(result.status.toString());

if (result.status == FacebookLoginStatus.loggedIn) {
   FirebaseUser user = await _auth.????/

  }

}

Solution

I was able to figure it out, I needed to have "signInWithCredential(FacebookAuthProvider.getCredential(accessToken:))" instead of signInWithFacebook.I saw it is the same for Google sign in, where instead of using "FacebookAuthProvider" you need to use "GoogleAuthProvider"!



Answered By - Ricardo Oscar Kanitz
Answer Checked By - Marilyn (PHPFixing Volunteer)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.