flutter_facebook_auth plugin not clearing the data when logging out
There is already an issue on the github project of the flutter_facebook_auth 3.5.0
here.
It looks like an lmitation of Facebook and not the plugin itself.
xpetta
Updated on December 01, 2022Comments
-
xpetta over 1 year
I'm making use of the
flutter_facebook_auth 3.5.0
plugin to enable users to log into my app using their Facebook account.Everything is working as expected. But when I log out and try to login again, it isn't prompting me to enter the credentials and directly logs me in.
I want it to prompt the user to enter their Facebook account credentials and then log into the app only if the authentication was successful.
Below is the SignIn code:
Future<void> signInWithFacebook(BuildContext context) async { User? firebaseUser; LoginResult response = await FacebookAuth.instance.login(); AuthCredential facebookCredential = FacebookAuthProvider.credential(response.accessToken!.token); final UserCredential userCredential = await FirebaseAuth.instance.signInWithCredential(facebookCredential); firebaseUser = userCredential.user; switch (response.status) { case LoginStatus.success: final userData = await FacebookAuth.instance.getUserData(); facebookUserData = userData; firestoreInstance.collection("users").doc(firebaseUser!.uid).set({ "userID": firebaseUser.uid, "name": facebookUserData["name"], "photo": facebookUserData["picture"]["data"]["url"], "emailAddress": facebookUserData["email"], "signUpMethod": "facebook", "accountCreatedOn": Timestamp.now(), "receiveOffers": true, "isAdmin": false, "isAuth": false, "isSubscribed": false, }); Navigator.of(context).pushReplacement(ScaledAnimationPageRoute(HomePage())); break; case LoginStatus.cancelled: print("Facebook: User cancelled login"); break; case LoginStatus.failed: print("Facebook: Login error!"); break; case LoginStatus.operationInProgress: // TODO: Handle this case. break; } }
Below is the method for logout:
await FacebookAuth.instance.logOut(); facebookUserData = {}; await authInstance.signOut().then((value) => Navigator.of(context).pushReplacement(ScaledAnimationPageRoute(SignIn())));
I think the
AuthCredential
needs to be cleared when the user is logging out. I'm not sure how to do it.I'm new to Flutter. How can I fix this?
-
A-P over 2 yearsDid you got the solution for above?
-