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.

Password:test
Salt: salt

Password+salt hashed in SHA512:

6c838e934e3feefae6cfa53af11375d4954f85c6f5ed888c02cd7806a71696d1cb449f2be78e9e6ea301a95c81f28ad8766f3ae582f9beaac33c7dc2b7ba9187

Base-64 encoded password+salt:

NmM4MzhlOTM0ZTNmZWVmYWU2Y2ZhNTNhZjExMzc1ZDQ5NTRmODVjNmY1ZWQ4ODhjMDJjZDc4MDZhNzE2OTZkMWNiNDQ5ZjJiZTc4ZTllNmVhMzAxYTk1YzgxZjI4YWQ4NzY2ZjNhZTU4MmY5YmVhYWMzM2M3ZGMyYjdiYTkxODc=

Base-64 encoded salt:

c2FsdA==

User.json:

{
  "users": [
    {
      "localId": "123",
      "emailVerified": true,
      "email": "test@demo.com",
      "passwordHash": "NmM4MzhlOTM0ZTNmZWVmYWU2Y2ZhNTNhZjExMzc1ZDQ5NTRmODVjNmY1ZWQ4ODhjMDJjZDc4MDZhNzE2OTZkMWNiNDQ5ZjJiZTc4ZTllNmVhMzAxYTk1YzgxZjI4YWQ4NzY2ZjNhZTU4MmY5YmVhYWMzM2M3ZGMyYjdiYTkxODc=",
      "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

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

  1. 518827 130212An attention-grabbing dialogue is value comment. I believe which you require to write a lot more on this matter, it wont be a taboo subject nevertheless normally individuals are not sufficient to speak on such topics. Towards the next. Cheers 829715

    Reply

Leave a Comment