Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Transfer registered users from one firebase app to another

Tags:

firebase

My firebase app has a list of registered users. These were created with Email & Password Authentication.

I want to transfer the firebase data and the list of users to another firebase app.

Transferring the firebase data is straightforward, but how can I transfer the registered users and keep their uid's?

Is this possible and if so, what is the best way to do it?

like image 255
Dan Avatar asked Mar 16 '16 10:03

Dan


People also ask

How do I get all users from Firebase authentication?

If you want to view a list of users that has registered thru Firebase Auth, you may view them in https://console.firebase.google.com/ then go to your project and select authentication , in the Users list is all the users that have registered thru Firebase Auth.

Where are users stored in Firebase?

Firebase users have a fixed set of basic properties—a unique ID, a primary email address, a name and a photo URL—stored in the project's user database, that can be updated by the user (iOS, Android, web).


2 Answers

You should use the Firebase admin tools.

You may install the admin tools using this command:

npm install -g firebase-tools 

Export command, that generates the AllUsers.json file:

firebase auth:export AllUsers.json --project projectId 

On the other account use the following command to import the generated file.

firebase auth:import AllUsers.json --project projectId 
like image 112
Genaro Costa Avatar answered Sep 25 '22 13:09

Genaro Costa


The answer above doesn't work by it self as all the passwords from the previous project will have different password hashes. You need to specify the old hash (exporting project) when you import the new users.

enter image description here

Click on this menu item and all of the settings you need for doing the firebase auth:import command will show up. Here's what I see:

hash_config {   algorithm: SCRYPT,   base64_signer_key: <long string of random characters>,   base64_salt_separator: <short string of random characters>,   rounds: 8,   mem_cost: 14, } 

I can then do the command successfully

firebase auth:import ./users.json --hash-algo=scrypt --rounds=8 --mem-cost=14 --hash-key=<long string of random characters> --salt-separator=<short string of random characters> 

How to set hash-key option for auth:import after default auth:export in firebase?

like image 37
Ben Winding Avatar answered Sep 22 '22 13:09

Ben Winding