Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create test users during development with Firebase?

I recently started building my first Firebase app, and I'm unsure how to create test users.

For non-user test data, I can keep a testdata.json file in my codebase and import it via the Firebase Console, but there doesn't seem to be an equivalent mechanism for users.

I'm aware that the latest version of firebase-tools (v3.2.0, released 4 days ago) added an auth:import command, but when I checked the docs, I saw that it expected password hashes to be pre-generated, which is not something I know how or want to do manually.

If there was an equivalent auth:export command that generated a file appropriate for feeding to auth:import, then I could use the Firebase Console to manually create a few users, export them to a file, and check it into my codebase (just like testdata.json), but there is no such command.

Even then, the fact that the Firebase Console doesn't let you set basic profile attributes (like displayName) on users is yet another obstacle...

like image 913
odigity Avatar asked Aug 05 '26 20:08

odigity


2 Answers

There are three ways to create email/password users:

  1. through the API
  2. through the Firebase Console
  3. by importing them with the Firebase CLI

For your use-case all three of these sound equally applicable. If you're having trouble getting one working, edit your question to include the minimal steps that reproduce the problem. If you'd like to request a fourth way, I recommend filing a feature request.

like image 174
Frank van Puffelen Avatar answered Aug 09 '26 12:08

Frank van Puffelen


For anyone following along with this post, it appears the Firebase CLI added this export feature:

firebase auth:export users.json

However it's not clear to me how user password hashes are preserved for auth:import

like image 33
otri Avatar answered Aug 09 '26 11:08

otri



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!