Delete all users from firebase auth console
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.
Maximus S
Updated on July 05, 2022Comments
-
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 over 7 yearsCan 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 over 7 yearsThanks a lot...works great..saves me 2 clicks and moving the mouse around :)
-
makkasi over 7 yearsCan 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 over 7 yearsin the NodeJs firebase-admin SDK is there no way to get all users then for each user
admin.auth().deleteUser(uid);
-
Aldasa over 7 yearsIs this right so far? "Löschen" = "Delete" "Konto löschen" = "Delete account" "Nutzermenü öffnen" = ?
-
Luis Mejía F. over 7 yearsThanks, this is really helpful :)
-
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 over 7 yearsyo, very useful bro)
-
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 over 7 yearsThanks, bro. Very helpful. :)
-
mjpablo23 about 7 yearshow do i run this script?
-
Ionică Bizău about 7 years@mjpablo23 Open the browser developer tools (Right click on the page and
Inspect
orInspect Element
), then go to theConsole
tab and paste the code and press the return / enter key. -
mjpablo23 about 7 yearswhat do I right click on? I'm on the Firebase->Authentication page in the Firebase console.
-
Ionică Bizău about 7 years@mjpablo23 Simply right click anywhere on the page.
-
KrauseFx about 7 yearsThis works, however make sure to have the tab open not switch to a different one while it's running
-
Drew Szurko about 7 yearsWorked for me too. Thanks. It's sad this has to be the workaround.
-
brs14ku about 7 yearsYes! Thank you. The delay was needed apparently.
-
ashish almost 7 yearsHow to delete only single user by uid?
-
Yassine ElBadaoui over 6 yearsYou deserve a Nobel prize for this answer! 😜
-
raiser00 over 6 yearsAm 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 about 6 yearsPlease provide some explanation
-
Sebastian Ortmann almost 6 years200 ms was short in my case. Set to 1000 - 1500 ms and it works!
-
Eugene Hauptmann almost 6 yearshaha, 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 over 5 yearsI didn't even know that I could run Javascript in the console. Lessons learned. Learn the basics of other things too.
-
Nguyen Thanh about 5 yearsThis script is better than the others!
-
gbhall about 5 yearsThis was awesome to watch in action! Thank you to you.
-
Eugene Hauptmann almost 5 years@gbhall ahahaha, glad you had fun with it.
-
Jorsh almost 5 yearsThis worked for me. I'm blocked right now tho, api didn't let me delete more about 8,000 users in
-
Sunit Gautam almost 5 yearsGlad it worked. However, I did not face any blocking or restrictions when I tried it.
-
Murtuza over 4 yearsI had slow internet sow I had to put interval of 5000
-
Eugene Hauptmann over 4 yearsThat's cool @Murtuza ideally it would be linked to the event handler when XHR requests are finished.
-
howdoyouturnthison over 4 yearsThanks, 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 over 4 yearsThanks! you saved 342 clicks and 228 mouse moves 😆
-
Daniel Fowler over 4 yearsConfirmed 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 over 4 yearsI love this solution! I'm adding an if statement to count for the need to go to the next page though.
-
Eugene Hauptmann over 4 yearshey @Chris, great to hear! Feel free to share your solution. Let's make firebase easier for us all :)
-
Chris over 4 years@www.eugenehp.tk posted :)
-
Ayyappa about 4 yearsWhen trying this script, set "Rows per page" to max and run.
-
SuperUberDuper about 4 yearsjust dont let the general public have access to this
-
SuperUberDuper about 4 yearswhy cant you tab away?
-
ErraticFox about 4 years@Aldasa "Open user menu" is Nutzermenü öffnen
-
Narcis almost 4 yearsBrilliant solution, works like a charm! Thank you! 🙌🏽
-
ZF007 over 3 yearsIf 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 over 3 yearsDoesn't work for me. Just says 'interval cleared'
-
AAverin over 3 yearsI 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 over 3 yearsNice. 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 about 3 yearsThis 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 about 3 yearsYou are the best :). This works in 21.04.2021
-
b.john about 3 yearshow does this work>? where exactly do i write this code
-
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 about 3 yearsI 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 almost 3 yearsThis 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 over 2 yearsTHANK YOU, out of all the answers, this one worked perfectly, appreciate it!!!! <3
-
Greg Sadetsky over 2 yearsStill works as of Jan 7 2021. Thank you so much!
-
Yaman KATBY over 2 years@GregSadetsky 2022* 🤩
-
Greg Sadetsky over 2 yearshaha, you're right, 2022*!! I'll keep my original comment for posterity. :-) Cheers and best wishes
-
Aezur over 2 yearsThat's some beautiful hackery. Still working 21 feb 2022.
-
Ant1k over 2 yearsThanks. Crazy that this is still needed in 2022.
-
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 about 2 yearsHere's it as a gist you can save: gist.github.com/joshpetit/b6cf918a9beac1f4e86270475a61cb11