0
votes

did anybody had to delete user from Firebase auth, without being logged in.

In Firebase API to delete user is:

https://identitytoolkit.googleapis.com/v1/accounts:delete?key=[API_KEY]

and I have to provide idToken "The Firebase ID token of the user to delete".

I have database of users.. and when I have to delete some user how I can obtain idToken.. as I am admin and I want to just delete user, I don't know user's password in order to login and obtain idToken...

My question is, can user be deleted by just sending user's UID or... can I obtain idToken without user's password.

Thank you!

1

1 Answers

0
votes

In order to get the idtoken of a user you need to call the Refresh token API

https://firebase.google.com/docs/reference/rest/auth#section-refresh-token

This gives you an idtoken as a response and then you can call the delete API

https://firebase.google.com/docs/reference/rest/auth#section-delete-account

The easiest way you can delete users in bulk is discussed here

Deleting users in bulk in Firebase

You just need to read the uids from a file (say csv).

If there are less than 20 users, the best way is to delete via the Firebase Web console by searching the uid of user you want to delete.

Delete a Firebase user