Delete all users from firebase auth console

2019-01-31 19:11发布

问题:

Is there an easy way to delete all registered users from firebase console? For example, I created a hundred users from my development environment, and now I want to delete all of them.

回答1:

firebaser here

Update 2016-11-08 original answer below

We just released the Firebase Admin SDK, which supports administrative use-cases, such as deleting a user account without requiring that user to sign in first.

original answer

There is currently no API in Firebase Authentication to delete a user without requiring that user to sign in. We know this limits the usability of our API and are working to add such functionality in a future release. But as usual, we don't provide specific timelines for when the feature will be available.

For the moment your only work arounds are to:

  • sign in as each test user in the app and delete the user from there
  • delete each user in turn from the Firebase Console


回答2:

As in updated answer, you can probably use firebase admin tools now, but if you don't want – here is a bit more solid javascript to remove users in the web:

var intervalId;

var clearFunction = function() {
  if ($('[aria-label="Delete account"]').size() == 0) {
    console.log("interval cleared")
    clearInterval(intervalId)
    return
  }
  $('[aria-label="Delete account"]')[0].click();
  setTimeout(function () {
     $(".md-raised:contains(Delete)").click()
  }, 1000);
};

intervalId = setInterval(clearFunction, 3000)

Just run it in developer tools



回答3:

Because I'm pretty lazy at clicking buttons and elements in the UI, I set up a small client script:

$('[aria-label="Delete account"]').click()
setTimeout(function () {
   $(".md-raised:contains(Delete)").click()
}, 1000);

You may need to run it multiple times, but it is much better than wasting the time clicking things on the screen manually.



回答4:

Slightly increased your helper script.

German firebase site version:

$('[aria-label="Nutzermenü öffnen"]').click();
$('[aria-label="Konto löschen"]').click();
for (i = 0; i < 20; i++) {
  setTimeout(() => {
    $('.md-raised:contains(Löschen)').click();
  }, i * 200);
}

For the english version just replace the text. This way you can delete 20 or more users once executed.



回答5:

Here is my bicycle: