FusionAuth
    • Home
    • Categories
    • Recent
    • Popular
    • Pricing
    • Contact us
    • Docs
    • Login

    CORS error while importing Users

    Scheduled Pinned Locked Moved Solved
    Q&A
    2
    8
    1.1k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      sandesh
      last edited by

      Scenario while importing Users from JSON file - after resolving the CORS, getting a response as show below. Would like to know what configuration is suitable for FusionAuth CORS to allow User import to work?

      Screenshot from 2023-07-26 14-22-19.png

      Also, check the below images for further reference -
      callApiWithJsonData(...) -> Where actual call is happening ...
      convertFirebaseToFusion --> Reference for User Data structure

      Screenshot from 2023-07-26 14-34-14.png

      S 1 Reply Last reply Reply Quote 0
      • S
        sandesh @sandesh
        last edited by

        Error shown in console is as below -
        Unknown scheme, whereas, I want to save the password as default password. There is no reason to ask for Scheme.
        Screenshot from 2023-07-27 08-58-24.png

        danD 1 Reply Last reply Reply Quote 0
        • danD
          dan @sandesh
          last edited by

          Hi @sandesh,

          Thanks for using FusionAuth.

          It is more typical to import users from a server side process, but there's no API restriction that prevents it.

          It seems like if you omit an encryptionScheme on the user object, FusionAuth will treat the password as plaintext. From the docs:

          users[x].encryptionScheme [String] Optional defaults to salted-pbkdf2-hmac-sha256
          The method for encrypting the User’s password. If the password value is already encrypted this value is required.
          Omitting this value indicates the password is in plain text and it will be encrypted using the default password encryptor.

          Can you share a bit of your import JSON (one or two users)?

          --
          FusionAuth - Auth for devs, built by devs.
          https://fusionauth.io

          S 1 Reply Last reply Reply Quote 0
          • S
            sandesh @dan
            last edited by sandesh

            @dan I agree Dan, I saw documentation and decided not to use the scheme and encrypt using default method of Fusionauth. I even tried after removing salt parameter and setting the default password as - 123123. Still facing the same issue. Here are couple of Users which I am trying to migrate -

            {"users": [
            {
            "localId": "14fP6HjVVEMmBphn3gJSF7WPjrY2",
            "email": "g.vikas@pm.me",
            "emailVerified": true,
            "passwordHash": "8VCNbPGEelyjrDM/G51O97rOiQ2/4rTlFMiFy6Wxnw/gUbfBz3No93/stcbunU3/XM+RbCQYq2t7deVXHw8RzQ==",
            "salt": "3mES5SUwakkouw==",
            "displayName": "vikas asadf",
            "lastSignedInAt": "1672216572913",
            "createdAt": "1664788494325",
            "providerUserInfo": []
            },
            {
            "localId": "b9YMS5fqNeXX2dCcAnxSl1yFAyG3",
            "email": "sandesh@pm.com",
            "emailVerified": true,
            "passwordHash": "DkeD4bCS0awG42rhNty1RfAsQb5DUdVhYo2LNmKgVFGj2bqPKOGTdnRZwigOarslNIM6/0EcAlTpKvc+3o+5bA==",
            "salt": "0yCVEp3/yykh/Q==",
            "displayName": "Sandesh asdad",
            "lastSignedInAt": "1684406569761",
            "createdAt": "1671419702169",
            "providerUserInfo": []
            }
            ]}

            danD 1 Reply Last reply Reply Quote 0
            • danD
              dan @sandesh
              last edited by dan

              @sandesh passwordHash is not a valid parameter, neither is providerUserInfo, emailVerified or localId, so this would never work. Please consult the import API documentation to check to see you are creating the JSON correctly: https://fusionauth.io/docs/v1/tech/apis/users#request-7

              If you are providing the password in a hash, you need to provide the encryptionScheme and the hash value in the password field.

              If you are not providing the hashed password, omit the encryptionScheme and provide a plaintext value in the password field, such as 123123, as you suggest.

              --
              FusionAuth - Auth for devs, built by devs.
              https://fusionauth.io

              S 1 Reply Last reply Reply Quote 0
              • S
                sandesh @dan
                last edited by

                Hey @dan , I shared you the pre-processed data, which is incorrect information. Please check the processed data that is used to import the Users.

                {
                "users":[{
                "email":"schneider.jochen@pm.me",
                "active":true,
                "fullname":"JOchen asadf",
                "passwordChangeRequired":true,
                "verified":true,
                "password":"123123"
                },
                {
                "email":"jochen.odsport@gmail.com",
                "active":true,
                "fullname":"Jochen fdshgsdhf",
                "passwordChangeRequired":true,
                "verified":false,
                "password":"123123"
                }
                ]}

                S 1 Reply Last reply Reply Quote 0
                • S
                  sandesh @sandesh
                  last edited by

                  @dan I tried using javascript when tried using POSTMAN, it is working fine. We can close this ticket.

                  danD 1 Reply Last reply Reply Quote 1
                  • S sandesh has marked this topic as solved on
                  • danD
                    dan @sandesh
                    last edited by

                    @sandesh Great, glad you figured it out!

                    --
                    FusionAuth - Auth for devs, built by devs.
                    https://fusionauth.io

                    1 Reply Last reply Reply Quote 0
                    • First post
                      Last post