0

I have few authenticate users in the user list. And I want to remove one of them. Firebase documentation suggest me to use this code for remove any user.

admin.auth().deleteUser(id)
 .then(function() {
    console.log('Successfully deleted user');
 })
 .catch(function(error) {
    console.log('Error deleting user:', error);
});

So I use it in my project like this way. I use firebase.auth instead of admin.auth. so my code is like this.

firebase.auth().deleteUser(id)
   .then(function() {
      console.log('Successfully deleted user');
   })
   .catch(function(error) {
      console.log('Error deleting user:', error);
});

But it not working. Shows an error like this

deleteUser is not a function
Christopher Peisert
  • 21,862
  • 3
  • 86
  • 117

1 Answers1

2

The deleteUser function is defined for the Firebase Admin SDK. It appears that you are using the client-side JavaScript SDK. The Admin SDK needs to run on your web server, whereas the client-side JavaScript SDK would run in the browser.

For an overview on how to delete an individual user (or multiple users), see Delete a user.

Firebase Admin SDK

The Admin SDK lets you interact with Firebase from privileged environments to perform actions like:

  • Read and write Realtime Database data with full admin privileges.
  • Programmatically send Firebase Cloud Messaging messages using a simple, alternative approach to the FCM server protocols.
  • Generate and verify Firebase auth tokens.
  • Access Google Cloud Platform resources like Cloud Storage buckets and Firestore databases associated with your Firebase projects.
  • Create your own simplified admin console to do things like look up user data or change a user's email address for authentication.

If you are interested in using the Node.js SDK as a client for end-user access (for example, in a Node.js desktop or IoT application), as opposed to admin access from a privileged environment (like a server), you should instead follow the instructions for setting up the client JavaScript SDK.

Christopher Peisert
  • 21,862
  • 3
  • 86
  • 117