How to delete FirebaseAuth currentUser created with custom token

Viewed 203

I am not having any problems deleting the current user if they're signed in with one of the standard providers (e.g. Google).

However when I use the await FirebaseAuth.instance.currentUser.delete() for a user logged in with a custom Token (in my instance, created with Firebase Admin in a cloud function with a LINE token), I don't receive any errors, but the user also isn't deleted from Firebase when I check the console.

my delete user code:

Future<void> deleteAccount() async {
    try {
      await FirebaseAuth.instance.currentUser.delete();
    } on FirebaseAuthException catch (e, s) {
      if (e.code == 'requires-recent-login') {
        print(
            'The user must reauthenticate before this operation can be executed.');
        await signInWithLine();
        await FirebaseAuth.instance.currentUser.delete();
      } else {
        print('Firebase auth delete account error:\n$e');
        print('============stack=========\n$s');
      }
    } catch (e, s) {
      print('Firebase auth delete account error:\n$e');
      print('============stack=========\n$s');
    }
  }

Am I missing an extra step that needs to be taken to delete the user if their auth record was created with FirebaseAuth.instance.signInWithCustomToken(customToken) instead of FirebaseAuth.instance.signInWithCredential(oauthCredential)?

0 Answers
Related