Delete all users from firebase auth console

40,320

Solution 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

Solution 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() {
  var size = $('[aria-label="Delete account"]').size()
  if (size == 0) {
    console.log("interval cleared")
    clearInterval(intervalId)
    return
  }
  var index = Math.floor(Math.random() * size)
  $('[aria-label="Delete account"]')[index].click();
  setTimeout(function () {
     $(".md-raised:contains(Delete)").click()
  }, 1000);
};

intervalId = setInterval(clearFunction, 300)

Just run it in developer tools

Solution 3

For the new Firebase update

Try this code for the latest Firebase update. Open the console, paste this code and hit enter!!!

setInterval(() => {
    document.getElementsByClassName('edit-account-button mat-focus-indicator mat-menu-trigger mat-icon-button mat-button-base')[0].click()
    let deleteButtonPosition = document.getElementsByClassName('mat-focus-indicator mat-menu-item ng-star-inserted').length - 1
    document.getElementsByClassName('mat-focus-indicator mat-menu-item ng-star-inserted')[deleteButtonPosition].click()
    document.getElementsByClassName('confirm-button mat-focus-indicator mat-raised-button mat-button-base mat-warn')[0].click()
}, 1000)

Solution 4

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.

Solution 5

setInterval(() => {
  $('[aria-label="Delete account"]').first().click()
  setTimeout(()=>{
    $(".md-raised:contains(Delete)").click()
  }, 100)
}, 2000);

designed to avoid calling delete endpoint very often, since google fails with 404 error.

Share:
40,320
Maximus S
Author by

Maximus S

Updated on July 05, 2022

Comments

  • Maximus S
    Maximus S almost 2 years

    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.

  • DrZaphod
    DrZaphod over 7 years
    Can you please consider removing the 'Are you sure prompt' in the Firebase Console if you 'Shift' + click 'Delete account'. This would mimic the behaviour in the database and would significantly speed things up.
  • krv
    krv over 7 years
    Thanks a lot...works great..saves me 2 clicks and moving the mouse around :)
  • makkasi
    makkasi over 7 years
    Can I "sign in as each test user" from appengine , without browser? Can I delete users from app engine directly somehow or via some web services?
  • Snewedon
    Snewedon over 7 years
    in the NodeJs firebase-admin SDK is there no way to get all users then for each user admin.auth().deleteUser(uid);
  • Aldasa
    Aldasa over 7 years
    Is this right so far? "Löschen" = "Delete" "Konto löschen" = "Delete account" "Nutzermenü öffnen" = ?
  • Luis Mejía F.
    Luis Mejía F. over 7 years
    Thanks, this is really helpful :)
  • Ionică Bizău
    Ionică Bizău over 7 years
    @LuisMejíaF. I expected it to be useful when posting the answer :) Always, automate the stuff when there's something repetitive to do :-)
  • Mark Okhman
    Mark Okhman over 7 years
    yo, very useful bro)
  • makkasi
    makkasi over 7 years
    @Frank van Puffelen I see there is not python admin SDK. Is there some way to use the nodeJS admin SDK inside python.
  • Thanh Truong
    Thanh Truong over 7 years
    Thanks, bro. Very helpful. :)
  • mjpablo23
    mjpablo23 about 7 years
    how do i run this script?
  • Ionică Bizău
    Ionică Bizău about 7 years
    @mjpablo23 Open the browser developer tools (Right click on the page and Inspect or Inspect Element), then go to the Console tab and paste the code and press the return / enter key.
  • mjpablo23
    mjpablo23 about 7 years
    what do I right click on? I'm on the Firebase->Authentication page in the Firebase console.
  • Ionică Bizău
    Ionică Bizău about 7 years
    @mjpablo23 Simply right click anywhere on the page.
  • KrauseFx
    KrauseFx about 7 years
    This works, however make sure to have the tab open not switch to a different one while it's running
  • Drew Szurko
    Drew Szurko about 7 years
    Worked for me too. Thanks. It's sad this has to be the workaround.
  • brs14ku
    brs14ku about 7 years
    Yes! Thank you. The delay was needed apparently.
  • ashish
    ashish almost 7 years
    How to delete only single user by uid?
  • Yassine ElBadaoui
    Yassine ElBadaoui over 6 years
    You deserve a Nobel prize for this answer! 😜
  • raiser00
    raiser00 over 6 years
    Am glad to know this is now possible via firebase admin sdk. Would be cool to know if these can also be uploaded and used as google https functions? TIA!
  • Burhanuddin Rashid
    Burhanuddin Rashid about 6 years
    Please provide some explanation
  • Sebastian Ortmann
    Sebastian Ortmann almost 6 years
    200 ms was short in my case. Set to 1000 - 1500 ms and it works!
  • Eugene Hauptmann
    Eugene Hauptmann almost 6 years
    haha, thanks @AndroidRuntimeException , now someone should release an international version (seeing all those different languages above) and a version with official API, and this post will become ideal, lol
  • Rethinavel
    Rethinavel over 5 years
    I didn't even know that I could run Javascript in the console. Lessons learned. Learn the basics of other things too.
  • Nguyen Thanh
    Nguyen Thanh about 5 years
    This script is better than the others!
  • gbhall
    gbhall about 5 years
    This was awesome to watch in action! Thank you to you.
  • Eugene Hauptmann
    Eugene Hauptmann almost 5 years
    @gbhall ahahaha, glad you had fun with it.
  • Jorsh
    Jorsh almost 5 years
    This worked for me. I'm blocked right now tho, api didn't let me delete more about 8,000 users in
  • Sunit Gautam
    Sunit Gautam almost 5 years
    Glad it worked. However, I did not face any blocking or restrictions when I tried it.
  • Murtuza
    Murtuza over 4 years
    I had slow internet sow I had to put interval of 5000
  • Eugene Hauptmann
    Eugene Hauptmann over 4 years
    That's cool @Murtuza ideally it would be linked to the event handler when XHR requests are finished.
  • howdoyouturnthison
    howdoyouturnthison over 4 years
    Thanks, but a few things I had to go add on. Required the addition of firebase-functions and also a private key to give the script credentials to run. Followed these steps: firebase.google.com/docs/admin/setup
  • Soorya
    Soorya over 4 years
    Thanks! you saved 342 clicks and 228 mouse moves 😆
  • Daniel Fowler
    Daniel Fowler over 4 years
    Confirmed this is still working in Jan. 2020. I was running anonymous users for about about a year, so now I'm using alternate browser to auto-click and delete 13,000 of them, 250 per page at a time (250 per page). THANKS!
  • Chris
    Chris over 4 years
    I love this solution! I'm adding an if statement to count for the need to go to the next page though.
  • Eugene Hauptmann
    Eugene Hauptmann over 4 years
    hey @Chris, great to hear! Feel free to share your solution. Let's make firebase easier for us all :)
  • Chris
    Chris over 4 years
    @www.eugenehp.tk posted :)
  • Ayyappa
    Ayyappa about 4 years
    When trying this script, set "Rows per page" to max and run.
  • SuperUberDuper
    SuperUberDuper about 4 years
    just dont let the general public have access to this
  • SuperUberDuper
    SuperUberDuper about 4 years
    why cant you tab away?
  • ErraticFox
    ErraticFox about 4 years
    @Aldasa "Open user menu" is Nutzermenü öffnen
  • Narcis
    Narcis almost 4 years
    Brilliant solution, works like a charm! Thank you! 🙌🏽
  • ZF007
    ZF007 over 3 years
    If you want to get possible rep for your answer then provide substantial more info to boos quality of your answer. 15 answer were before you...
  • melchoir55
    melchoir55 over 3 years
    Doesn't work for me. Just says 'interval cleared'
  • AAverin
    AAverin over 3 years
    I would suppose something changed in the UI of Firebase and script needs some updating. I wouldn't risk deleting my users at the moment, so if anyone will adjust the script for the changes, send me a message and I will update the answer.
  • Henrique Bruno
    Henrique Bruno over 3 years
    Nice. Here it complained about reaching the limit after ~100 removals, but just executed it again to finishing removing all. I recommend using .gitignore on the cred.json file.
  • the korovay
    the korovay about 3 years
    This works great, thanks! Just note: if there's an anonymous account in the list, change index in second 'getElementsByClassName' from 2 to 1. Also you can set shorter interval, i used 500.
  • Reinis
    Reinis about 3 years
    You are the best :). This works in 21.04.2021
  • b.john
    b.john about 3 years
    how does this work>? where exactly do i write this code
  • Yaman KATBY
    Yaman KATBY about 3 years
    @b.john - Go to the auth page in your firebase console - Open the dev console in your browser - Paste this code and hit enter
  • Yunus Yurtturk
    Yunus Yurtturk about 3 years
    I made it working by changing 2nd command's index to 1, not 2 => document.getElementsByClassName('mat-focus-indicator mat-menu-item ng-star-inserted')[1].click()
  • Vinasirajan Vilakshan
    Vinasirajan Vilakshan almost 3 years
    This works for me 17.09.2021. For users authenticate by mail id's just use [2] in second line and others who use mobile authentication use [1] in second line.
  • Tiger Abrodi
    Tiger Abrodi over 2 years
    THANK YOU, out of all the answers, this one worked perfectly, appreciate it!!!! <3
  • Greg Sadetsky
    Greg Sadetsky over 2 years
    Still works as of Jan 7 2021. Thank you so much!
  • Yaman KATBY
    Yaman KATBY over 2 years
    @GregSadetsky 2022* 🤩
  • Greg Sadetsky
    Greg Sadetsky over 2 years
    haha, you're right, 2022*!! I'll keep my original comment for posterity. :-) Cheers and best wishes
  • Aezur
    Aezur over 2 years
    That's some beautiful hackery. Still working 21 feb 2022.
  • Ant1k
    Ant1k over 2 years
    Thanks. Crazy that this is still needed in 2022.
  • Karol Be
    Karol Be over 2 years
    @Jorsh if you want ot avoid restrictions in my case simple timeout helped when calling getAllUsers again: setTimeout(() => { getAllUsers(listUsersResult.pageToken) }, 6000);
  • joshpetit
    joshpetit about 2 years