I am using Flutter to create a mobile application. I am using Firebase for authentication. My user logs in with Facebook. The user should reauthenticate him/her self when deleting the account. The documentation talks about reauthentication using email and password like this:
// Create a credential
EmailAuthCredential credential = EmailAuthProvider.credential(email: email, password: password);
// Reauthenticate
await FirebaseAuth.instance.currentUser.reauthenticateWithCredential(credential);
Since the user does not have an email and password but rather he is logged in with Facebook, I should reauthenticate the user with Facebook. I searched the documentation for this but I had no luck.
Could some one be kind and tell me how to do that.
I tried to log the user in with Facebook (even though he is already logged in) but was not successful. Her is what I tried:
FacebookLoginResult result = await FacebookLogin().logIn(permissions: [
FacebookPermission.publicProfile,
FacebookPermission.email,
]);
switch (result.status) {
case FacebookLoginStatus.success:
FacebookAccessToken? accessToken = result.accessToken;
if (accessToken == null) {
return null;
}
UserCredential userCredential = await _auth.signInWithCredential(
FacebookAuthProvider.credential(accessToken.token),
);
return userCredential;
case FacebookLoginStatus.cancel:
throw FirebaseAuthException(
code: 'ERROR_FACEBOOK_LOGIN_FAILED',
message: result.error?.developerMessage,
);
default:
throw UnimplementedError();
}
await FirebaseAuth.instance.currentUser?.reauthenticateWithCredential(
userCredential!.credential!,
);