# "Wrong email or password" after bulk user import

**URL:** <https://community.auth0.com/t/wrong-email-or-password-after-bulk-user-import/93995>\
**Category:** Get Help\
**Tags:** bulk-user-import, password-hash\
**Created:** [November 8, 2022, 8:55pm UTC](https://community.auth0.com/t/wrong-email-or-password-after-bulk-user-import/93995 "2022-11-08T20:55:12Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![a111](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/a111/32/33896_2.png) [@a111](https://community.auth0.com/u/a111)\
**Post date:** [November 8, 2022, 8:55pm UTC](https://community.auth0.com/t/wrong-email-or-password-after-bulk-user-import/93995/1 "2022-11-08T20:55:13Z")

</div>

I am trying to bulk import users to Auth0. We don’t use their standard hashing algorithm, so I’ve had to convert our hashes to fit their “custom\_password\_hash” requirements. However, when I try to log in as one of those users, the Auth0 gives an incorrect password error.

Here is how we were generating salts and hashes pre Auth0:

```auto
var salt = crypto.randomBytes(32).toString('hex');
var hash = crypto
    .pbkdf2Sync(password, salt, 10000, 64, 'sha512')
    .toString('hex');

```

Here is how I am creating the custom\_password\_hash object Auth0 requests for each user to be imported:

```auto
const phcobj = {
    id: 'pbkdf2-sha256',
    params: {i: 10000, l: 64},
    salt: Buffer.from(salt, 'base64'), // create a binary buffer from base64 encoded string
    hash: Buffer.from(hash, 'base64'), 
  };
  const serialized = phc.serialize(phcobj);
  return {
    "algorithm": 'pbkdf2',
    "hash": {
      "value": serialized,
      "encoding": "utf8"
    }
  }

```

I am following the requirements for pbkdf2 hashes described here: [Bulk User Import Database Schema and Examples](https://auth0.com/docs/manage-users/user-migration/bulk-user-import-database-schema-and-examples#pbkdf2)

I am able to successfully import users via the Auth0 import/export extension. The users appear in the user management section (though without any password appearing in “raw json”, but maybe this is normal.

But when I go to log in, I get an error “Wrong email or password”. This is unexpected. I should just be able to log in.

What am I missing?

---

<div class="post-metadata">

**Author:** ![a111](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/a111/32/33896_2.png) [@a111](https://community.auth0.com/u/a111)\
**Post date:** [November 9, 2022, 11:44pm UTC](https://community.auth0.com/t/wrong-email-or-password-after-bulk-user-import/93995/2 "2022-11-09T23:44:03Z")

</div>

Additionally, the `user_id` I imported is not reflected on the user once imported (according to my “users” tab).

---

<div class="post-metadata">

**Author:** ![akash.dhiwar\_6](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@akash.dhiwar\_6](https://community.auth0.com/u/akash.dhiwar_6)\
**Post date:** [November 1, 2023, 11:36am UTC](https://community.auth0.com/t/wrong-email-or-password-after-bulk-user-import/93995/3 "2023-11-01T11:36:09Z")

</div>

I’m also getting same issue did you fix it???

---

<div class="post-metadata">

**Author:** ![akash.dhiwar\_6](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@akash.dhiwar\_6](https://community.auth0.com/u/akash.dhiwar_6)\
**Post date:** [November 1, 2023, 12:12pm UTC](https://community.auth0.com/t/wrong-email-or-password-after-bulk-user-import/93995/4 "2023-11-01T12:12:34Z")

</div>

heyyyy , @rueben.tiow need some help here ! going through same issue need some assist. not able to login with migrated users

---

<div class="post-metadata">

**Author:** ![sleepylemur](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@sleepylemur](https://community.auth0.com/u/sleepylemur)\
**Post date:** [November 8, 2023, 6:33pm UTC](https://community.auth0.com/t/wrong-email-or-password-after-bulk-user-import/93995/5 "2023-11-08T18:33:11Z")

</div>

Ran into this issue today and what the api needs is base64url encoded salt and hash, not hex encoded as shown in the “pre Auth0” example above. In our db we had hex encoded hashes and base64url encoded salts, so the hashes needed to be re-encoded as base64url before sending to Auth0.

Example js code to generate a password that Auth0 will process correctly:

```auto

const phc = require('@phc/format');
const crypto = require('node:crypto');

const password = 'password';
const salt = crypto.randomBytes(16);
const keylen = 32;
const iterations = 260000;
const digest = 'sha256';

const hash = crypto.pbkdf2Sync(password, salt, iterations, keylen, digest);

const phcobj = {
  id: `pbkdf2-${digest}`,
  params: {i: iterations, l: keylen},
  salt,
  hash,
};

const phcstr = phc.serialize(phcobj).toString('utf-8');

```

Actual json to send to the users-imports endpoint:

```auto
[
  {
    "email": "text@example.com",
    "custom_password_hash": {
      "algorithm": "pbkdf2",
      "hash": {
        "value": "$pbkdf2-sha256$i=260000,l=32$vHHCR+yr7MNdL/zoVHz56g$l1jPurS8vNa4yF504zdFxh5K+yWpNQGhah7I28f/Zbw",
        "encoding": "utf8"
      }
    }
  }
]

```

---

<div class="post-metadata">

**Author:** ![akash.dhiwar\_6](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@akash.dhiwar\_6](https://community.auth0.com/u/akash.dhiwar_6)\
**Post date:** [November 9, 2023, 5:03am UTC](https://community.auth0.com/t/wrong-email-or-password-after-bulk-user-import/93995/6 "2023-11-09T05:03:04Z")

</div>

hey @sleepylemur thanks this works . Can you do the same for sha256 ???

---

<div class="post-metadata">

**Author:** ![sleepylemur](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@sleepylemur](https://community.auth0.com/u/sleepylemur)\
**Post date:** [November 9, 2023, 3:04pm UTC](https://community.auth0.com/t/wrong-email-or-password-after-bulk-user-import/93995/7 "2023-11-09T15:04:45Z")

</div>

glad it works. we’re only importing pbkdf2-sha256 and i don’t have bandwidth to explore the other accepted formats. best of luck!

---

<div class="post-metadata">

**Author:** ![sleepylemur](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@sleepylemur](https://community.auth0.com/u/sleepylemur)\
**Post date:** [November 21, 2023, 4:59pm UTC](https://community.auth0.com/t/wrong-email-or-password-after-bulk-user-import/93995/8 "2023-11-21T16:59:21Z")

</div>

Update: I believe it is actually base64 encoded, not base64url encoded for both salt and hash.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [December 3, 2024, 2:56am UTC](https://community.auth0.com/t/wrong-email-or-password-after-bulk-user-import/93995/9 "2024-12-03T02:56:17Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
