https://supertokens.com/ logo
Title
f

funk101

12/13/2022, 11:12 AM
question about "data migration/user creation"; does this have to be done using cURL requests?
r

rp

12/13/2022, 11:15 AM
hey @funk101
yea it does. We don't have functions in the backend SDK for those. But you can always just use fetch / axios in your backend code as well
f

funk101

12/13/2022, 11:21 AM
hmm
I'm getting this error:
[Symbol(Response internals)]: {
    url: 'https://dev-5adad1716e1211ed8e078d5042b64ab1-us-east-1.aws.supertokens.io:3567/recipe/user/passwordhash/import',
    status: 401,
    statusText: 'Unauthorized',
    headers: Headers { [Symbol(map)]: [Object: null prototype] },
    counter: 0
  }
}
I "assume" I'm using the correct api-key
r

rp

12/13/2022, 12:33 PM
api key is wrong
f

funk101

12/13/2022, 12:33 PM
don't I use the "core api key"?
that's the only key I have
I just re-checked
r

rp

12/13/2022, 12:36 PM
right. You are querying the dev instance. So are you using the dev API key?
f

funk101

12/13/2022, 12:36 PM
yes
r

rp

12/13/2022, 12:37 PM
well.. is your app working when connected to the dev instance?
f

funk101

12/13/2022, 12:37 PM
yes
r

rp

12/13/2022, 12:37 PM
then there is some issue with how you are making the API call
im not sure what. It's on you to figure
f

funk101

12/13/2022, 12:37 PM
const url =
  "https://dev-5adad1716e1211ed8e078d5042b64ab1-us-east-1.aws.supertokens.io:3567/recipe/user/passwordhash/import";

const response = fetch(url, {
  method: "post",
  body: JSON.stringify({
    email: "jeff@jeffrenza.com",
    passwordHash:
      "$argon2i$v=19$m=16,t=2,p=1$TG9qbzU1NzE$rTOXWfhHVT+Q7wPn7PShSQ",
  }),
  headers: {
    "Content-Type": "application/json",
    api_key: "<my key>",
  },

});
response.then((res) => console.log("res: ", res));
r

rp

12/13/2022, 12:38 PM
it's
api-key
not
api_key
f

funk101

12/13/2022, 12:38 PM
argh
r

rp

12/13/2022, 12:38 PM
haha yeaa..
f

funk101

12/13/2022, 12:40 PM
yep, that was it, sorry 😭
r

rp

12/13/2022, 12:41 PM
no worries. happy to help
f

funk101

12/13/2022, 1:22 PM
So the response from that above logic doesn't send back the newly created supertokensId, right? I don' t see it in the response
r

rp

12/13/2022, 1:23 PM
it does.
f

funk101

12/13/2022, 1:32 PM
I don't see it, point me in the direction?
Response {
  size: 0,
  timeout: 0,
  [Symbol(Body internals)]: {
    body: PassThrough {
      _readableState: [ReadableState],
      _events: [Object: null prototype],
      _eventsCount: 2,
      _maxListeners: undefined,
      _writableState: [WritableState],
      allowHalfOpen: true,
      [Symbol(kCapture)]: false,
      [Symbol(kCallback)]: null
    },
    disturbed: false,
    error: null
  },
  [Symbol(Response internals)]: {
    url: 'https://dev-5adad1716e1211ed8e078d5042b64ab1-us-east-1.aws.supertokens.io:3567/recipe/user/email/verify/token',
    status: 200,
    statusText: 'OK',
    headers: Headers { [Symbol(map)]: [Object: null prototype] },
    counter: 0
  }
}
oops, wrong response, that's for verification, hang on...
Response {
  size: 0,
  timeout: 0,
  [Symbol(Body internals)]: {
    body: PassThrough {
      _readableState: [ReadableState],
      _events: [Object: null prototype],
      _eventsCount: 2,
      _maxListeners: undefined,
      _writableState: [WritableState],
      allowHalfOpen: true,
      [Symbol(kCapture)]: false,
      [Symbol(kCallback)]: null
    },
    disturbed: false,
    error: null
  },
  [Symbol(Response internals)]: {
    url: 'https://dev-5adad1716e1211ed8e078d5042b64ab1-us-east-1.aws.supertokens.io:3567/recipe/user/passwordhash/import',
    status: 400,
    statusText: 'Bad Request',
    headers: Headers { [Symbol(map)]: [Object: null prototype] },
    counter: 0
  }
}
again, that was a bad request, here's the response
Response {
  size: 0,
  timeout: 0,
  [Symbol(Body internals)]: {
    body: PassThrough {
      _readableState: [ReadableState],
      _events: [Object: null prototype],
      _eventsCount: 2,
      _maxListeners: undefined,
      _writableState: [WritableState],
      allowHalfOpen: true,
      [Symbol(kCapture)]: false,
      [Symbol(kCallback)]: null
    },
    disturbed: false,
    error: null
  },
  [Symbol(Response internals)]: {
    url: 'https://dev-5adad1716e1211ed8e078d5042b64ab1-us-east-1.aws.supertokens.io:3567/recipe/user/passwordhash/import',
    status: 200,
    statusText: 'OK',
    headers: Headers { [Symbol(map)]: [Object: null prototype] },
    counter: 0
  }
}
r

rp

12/13/2022, 1:39 PM
you might wanna read on up how read response body from fetch API call
f

funk101

12/13/2022, 1:50 PM
duh, got it thanks