SupabaseS
Supabaseβ€’3w ago
Nubartis

Getting otp_expired error when running verifyOtp

Hi everyone!

I've been hitting my head on a wall when trying to understand why this happens:

I have created a password less 6 digit login flow for both new users and existing ones following what I think is the right approach.

  1. Users enter their email addresses and click a button, the following is executed in my client code:
    supabaseClient.auth.signInWithOtp({ email });
  2. They correctly get created if not existing
  3. They correctly receive an email with a 6 digit token
  4. Then they introduce it and the following is executed
    const { error, data } = await supabaseClient.auth.verifyOtp({
         email: 'johndoe@gmail.com',
         token: '123456',
         type: 'email',
     });
  5. This returns always
{"code":"otp_expired","message":"Token has expired or is invalid"}


I can't see in the logs any explanation about the reason of this expiry or invalidity so I find myself completely unable to trace the cause of this. I know it must be something I am missing but I am really in the dark here πŸ˜…

Can someone lend me a hand? Many, many thanks in advance!
Was this page helpful?