I need to re-authenticate the user in order to delete his profile. I've already seen this answer How to re-authenticate a user on Firebase with Google Provider? but it doesn't work for me. In fact this code below eliminates correctly the user only if he has signed in recently. So in my code seems that user.reauthenticate(credential) doesn't work.
public void OnDeleteProfile(View view){
new AlertDialog.Builder(this)
.setPositiveButton("Delete", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
final FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
GoogleSignInAccount acct = GoogleSignIn.getLastSignedInAccount(getApplicationContext());
AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(),null);
user.reauthenticate(credential)
.addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
user.delete()
.addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
}
});
}
});
}
})
.setIcon(android.R.drawable.ic_dialog_alert)
.show();
}