Last active
June 24, 2024 05:56
-
-
Save mono0926/b0bf4acf5c16a84310b4bb17eae4511d to your computer and use it in GitHub Desktop.
Firebase Authenticationのユーザー一括削除 (`tsc`でビルドした後に`node GENERATED_JS.js`で実行)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as admin from 'firebase-admin'; | |
admin.initializeApp({ | |
credential: admin.credential.cert(__dirname + 'YOUR_KEY_RELATIVE_PATH'), | |
databaseURL: 'https://YOUR_PROJECT_ID.firebaseio.com', | |
}); | |
const sleep = (msec: number) => new Promise(resolve => setTimeout(resolve, msec)); | |
(async () => { | |
const users = await admin.auth().listUsers(); | |
for (const user of users.users) { | |
console.log(user.uid); | |
await admin.auth().deleteUser(user.uid); | |
await sleep(50); // 速すぎると`QUOTA_EXCEEDED`になるので適当に間隔を開ける | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment