As the developer or the administrator of an app built on Firebase, you may need to perform various user management tasks. These include:

  • Provisioning new user accounts for your app
  • Updating existing user accounts
  • Manually verifying and enabling user accounts
  • Disabling or deleting user accounts
  • Querying user profile information to populate dashboards or compile reports

The Firebase Admin SDK provides a powerful API for performing these kinds of user management tasks from privileged environments. Using the Admin SDK, you can program these capabilities directly into your admin consoles, dashboards and other backend services. Unlike the Firebase client SDK, the Admin SDK is initialized with a service account credential, which grants the SDK elevated privileges necessary to perform user management operations.

This is not a brand new feature. The Firebase Admin Node.js SDK has had a user management API for a while. However, we are happy to announce that this API is now also available in our Admin Java SDK starting from version 5.1.0. This is one of the most requested features for the Admin Java SDK, and we are certain many Firebase app developers are going to find it useful.

The Java user management API closely mirrors its Node.js counterpart. Specifically, it consists of five new methods:

  • getUser()
  • getUserByEmail()
  • createUser()
  • updateUser()
  • deleteUser()

Following code snippet shows how to use some of these new methods in practice. In this example we retrieve an existing user account, and update some of its attributes:

final FirebaseAuth auth = FirebaseAuth.getInstance();
Task task = auth.getUserByEmail("editor@example.com")
    .addOnSuccessListener(userRecord -> {
      System.out.println("Successfully fetched user data: " + userRecord.getUid());
      UpdateRequest update = userRecord.updateRequest()
          .setDisabled(false)        // Enable the user account
          .setEmailVerified(true); // Set the email verification status
      auth.updateUser(update);
    })
    .addOnFailureListener(e -> {
      System.err.println("Error fetching user data: " + e.getMessage());
    }); 

You can learn more about the Firebase user management API from the Admin SDK documentation. Additionally, head over to our Github repo to see how it is implemented. (Yes, it's all open source!). You can also help us further improve this API by providing us feedback and reporting issues. As always, we are open to all sorts of contributions including pull requests to our codebase. Happy coding with Firebase!