I’m trying to authenticate via Email OTP in the test environment. After calling loginOrCreate I then pass in the returned email_id as the method_id to the authenticate method and get the error that the email could not be found. I’m using the predefined sandbox@stytch.com email address so I don’t understand how it cannot be found when the first call succeeds. Here is a trace of the two calls and their inputs and responses:
calling stytch.otps.email.loginOrCreate
request:
{
"email": "sandbox@stytch.com"
}
response:
{
"email_id": "email-test-23873e89-d4ed-4e92-b3b9-e5c7198fa286",
"request_id": "request-id-test-7bf45c7b-a339-4ccf-81d6-1ff3f2453f1e",
"status_code": 200,
"user_created": false,
"user_id": "user-test-e3795c81-f849-4167-bfda-e4a6e9c280fd"
}
calling stytch.otps.authenticate
request:
{
"method_id": "email-test-23873e89-d4ed-4e92-b3b9-e5c7198fa286",
"code": "123456",
"session_duration_minutes": 10080
}
err: {
"type": "StytchError",
"message": "{\"status_code\":404,\"request_id\":\"request-id-test-bd38b4df-3643-4979-a41f-07322ad189a3\",\"error_type\":\"email_not_found\",\"error_message\":\"Email could not be found.\",\"error_url\":\"https://stytch.com/docs/api/errors/404#email_not_found\"}",
"stack":
Error: {"status_code":404,"request_id":"request-id-test-bd38b4df-3643-4979-a41f-07322ad189a3","error_type":"email_not_found","error_message":"Email could not be found.","error_url":"https://stytch.com/docs/api/errors/404#email_not_found"}
at request (/Volumes/OWC4TB/projects/lyfeplan/node_modules/.pnpm/stytch@12.32.0/node_modules/stytch/dist/shared/index.js:46:11)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async Object.<anonymous> (/Volumes/OWC4TB/projects/lyfeplan/apps/api/src/modules/auth/auth.routes.ts:97:18)
"status_code": 404,
"request_id": "request-id-test-bd38b4df-3643-4979-a41f-07322ad189a3",
"error_type": "email_not_found",
"error_message": "Email could not be found.",
"error_url": "https://stytch.com/docs/api/errors/404#email_not_found"
}