Firebase Admin SDK is rolling out a new API for importing users into Firebase projects in bulk. This is useful for developers who wish to migrate users from various external user stores into Firebase. The bulk import capability has been present in the Firebase CLI for a while. But the CLI can only import users that are stored in JSON or CSV files. In contrast, the Admin SDK enables developers to implement their own tools and services that import users into Firebase projects from arbitrary sources.
The new API supports importing up to 1000 users per invocation. Listing 1 shows how to use this API in Python.
The return value of the
import_users() method indicates how many users were imported successfully, and how many were failed. It is also possible to inspect the causes behind failed imports. Listing 2 illustrates how.
The new API also facilitates importing users with passwords. In that case the
ImportUserRecord must specify the password hash, and the configuration of the hashing algorithm should be passed to the
import_users() method. Listing 3 shows an example where some users with SHA256 password hashes are being imported into Firebase.
Admin SDK supports around a dozen password hashing algorithms including the modified variant of Scrypt that Firebase Auth uses by default. The new import users API is currently available in Node.js, Java and Python. The Go implementation is awaiting release, and chances are it will be available for use by the time you read this. Head over to the official documentation to get started, and as always feel encouraged to share your thoughts on how this feature can be improved further.