Importing users with hashed passwords into OKTA

My aim is to import existing users into OKTA (and keep their passwords same as before). I am using this python code from Okta developer website to create the hashed password (see below):

import hashlib
import base64
import json

password = “test password”

hashed = hashlib.sha1(bytes(password, ‘utf-8’))
result = {
“algorithm”: “SHA-1”,
“value”: base64.b64encode(hashed.digest()).decode(“ascii”),
print(json.dumps(result, indent=4))

After this, I am using the OKTA API call to test and create my test user but i cannot seem to login with the password set in this process.

Even with using the examples from the developer website exactly the same, I still cannot make it work. Wondering if something is wrong with the example code or am i missing something ?

Thanks so much for the help, in advance !

I assume you are following this sample
If so can you supply the entire API import command you use to import the user into Okta.

If I use,

curl --location --request POST 'https://{ORG}' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: SSWS {API_TOKEN}' \
--data-raw '{
  "profile": {
    "firstName": "Hashed",
    "lastName": "Pass",
    "email": "",
    "login": ""
  "credentials": {
    "password" : {
      "hash": {
        "algorithm": "SHA-1",
        "value": "LOsCqF9tTebCiy5Z/aiG1Sba+w0="

I am able to login fine using,
pass: ‘test password’