Introduction

This article is a short tutorial aimed at giving you a path to migrate users between two Firebase projects (or really any authentication service).

As I passed a good amount of my morning trying to figure out how to do this, I thought spreading the word on the internet could potentially help more people locating it.

The documentation on this matter is hoster by Google here. So if you like to work with docs and do not want to read my little tuto, feel free :)

Tutorial

Step 1: Firebase CLI

In order to perform the import, you will need to use the Firebase command line interface. You can install it without issues on your machine by entering this command into your terminal (npm users)

npm install -g firebase-tools

Continue with the login process and init your firebase repo. Once all is done, you are ready to import/export your auth users.

Step 2: Import users

To import users, go into the Firebase repo you just have inited, and enter the following command

firebase auth:export accounts.json --format=JSON

This will download your current users into your local machine. Make sure the file location is secured, not committed to any git repo and offline. You don’t want to leak your users’ passwords.

Step 3: Export users to new project

First, switch projects using

firebase use new-project-name

Then go to your Firebase dashboard and go to Authentication > three dots on the top of user card > Hash parameters. You will need this information.

Now to import the users enter (replace the with your config from Firebase)

firebase auth:import accounts.json \
> --hash-algo=<hash_algo> \
> --hash-key=<hash_key> \
> --salt-separator=<sale_sep> \
> --rounds=<rounds> \
> --mem-cost=<mem_cost>

Once successfully migrated, you should receive something like

Processing accounts.json (XXXX bytes)
Starting importing 15678 account(s).
✔  Imported successfully.

All done, you have successfully migrated your users.

Now before you migrate please make sure you have disabled access to your old project for all users in order not to have different data from one project to the other. Also make sure that the apps are correctly updated to use your new project’s config. If you respected that, the experience for your users should be seamless.

Have a great day of code! Mike


About me

I am a partner at MMPG Consulting, a firm active in the custom software development industry in the Spanish and Swiss markets.

For more content, you can add me on LinkedIn or shoot me a DM if you want to discuss specific topics, your software or an idea you want to implement.