Unable to login after importing user into Firebase Authentication

We are migrating users into Firebase Auth from legacy db who have their passwords hashed with SHA512.

We are able to successfully import the users into Firebase. However, when we try to login again with those users through Firebase Authentication, it gives an error:

Invalid password or this user has no password

Following are the details of code structure, the command used to import users, and the user.json that we are using.

Salt: salt

Password+salt hashed in SHA512:


Base-64 encoded password+salt:


Base-64 encoded salt:



  "users": [
      "localId": "123",
      "emailVerified": true,
      "email": "test@demo.com",
      "salt": "c2FsdA=="

Firebase command for importing user.json:

firebase --project=projectname auth:import user.json --hash-algo=SHA512 --rounds=80

Pleas let us know what we are missing here

Thank You

25 thoughts on “Unable to login after importing user into Firebase Authentication”

  1. You need to add the hash key and salt separator. You can find these details here.

    Console > Project > Authentication > Password hash paremeter

    The import command would be something like this.

    firebase auth:import dev-accounts.json --hash-algo=scrypt --rounds=8 --hash-key="your_hash_key" --salt-separator="your_salt_separator" --mem-cost=14
  2. I used SHA256, got the same issue, and solved it finally using the following Python code.
    Hope these codes are helpful.

    • create password hash and salt
      password_hash_base_64 = base64.standard_b64encode(hashlib.sha256("123456salt").digest())
      salt_base64 = base64.standard_b64encode("salt")
      print password_hash_base_64
      print salt_base64
    • import_account_sha256.json
      "users": [
          "localId": "166666",
          "email": "166666@qq.com",
          "emailVerified": false,
          "passwordHash": "5NL5SaQBwE6c0L1BDjHW+BtBOXQVH8RYwY0tGGw3khk=",
          "createdAt": "1613525311156",
          "salt": "c2FsdA==",
          "providerUserInfo": []
    • Firebase CLI
    firebase auth:import import_account_sha256.json --hash-algo=SHA256 --rounds=1 --hash-input-order=PASSWORD_FIRST
    • example
      enter image description here

Leave a Comment