8

I am trying to export and import user using the firebase CLI as per docs available here. My problem is that I want to also export the user claims, or at least be able to include custom claims when importing the user.

Basically to export I run on the CLI:

firebase auth:export test.json --format=json

And to import I run on the CLI:

firebase auth:import test.json \ --hash-algo:scrypt

The exported users don't hold the custom claims information.

At the moment, I am working with 2 custom claims, admin and access, pretty much as described here.

The problem is that I was not able to include the claims on the file without having an error returned. Is it feasible to import users with custom claims, if not, what is the correct procedure?

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
Estevao Santiago
  • 793
  • 2
  • 7
  • 30

1 Answers1

0

If the claims are not exported by the CLI, then you will have to use the Firebase Admin SDK to work with custom claims. Your code will iterate each UID, fetch the claims and store them somewhere, then update the claims when it's time to import.

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
  • 2
    Not the solution I am looking for. The first time the app is deployed, I must be able to deploy it with an user with admin claims, otherwise the user will never be able to login. The idea is similar to the deploy app such as Joomla, Wordpress, etc. You set the information of an admin user in order to continue. – Estevao Santiago Oct 01 '19 at 13:46
  • If the CLI doesn't perform the import and export the way you'd like, I'd say this is likely your only option, unless you want to modify the CLI. Source code is here: https://github.com/firebase/firebase-tools – Doug Stevenson Oct 01 '19 at 13:47