Supabase sends OTP and Magic Links at the same time!
Supabase sends OTP and Magic Links at the same time, when i try to sign in using signInWithOtp(), sometimes it sends me an otp code, and sometimes it sends magic links, how can i force it to only send otp codes?
36 Replies
You mean in the email you receive sometimes there is an otp and sometimes signin link?
or are you receiving 2 emails?
Yes, exactly
This depends on how you've configured Confirm Email setting https://supabase.com/dashboard/project/_/auth/providers
For example:
- If its a new user and you've Confirm Email turned on, then Confirmation email template will be sent
- if you've Confirm Email turned off, then even for new user Magic Link email template will be sent
So in your case, I believe in either confirm email template or magic link template you've added
{{.Token}} field and not in the other template


And in magic link template?

Yeah, this is why you face this issue. You need to add
{{.Token}} here as wellGreat!
It is sending the otp code, but it is also saying "Your Magic Link" as the title of the email, how can i fix that?

This looks like a gmail thing. All these messages seem to be in same thread. And its taking the title of the first email in the thread. Delete all these emails and retry signup. i believe that should show the correct title
I deleted them all, but still giving the same title


Thats odd. In this screenshot, the subject is set to Confirm Your signup. Let me test it on my end
Okay
I'm receiving the correct subject

Try making some changes in the confirmation email subject and click on save.
Hmm, that's strange
Okay
It worked!
Could be some cache issue.
Yes maybe, i've got another issue in verifying the otp code
When i enter the sent otp code, it says "Token has expired or is invalid", with a status code of "403"
Share the verifyOtp code
111302
no I mean the actual code you have in your app
not the otp
Okey!


Are you sure that you're passing the correct email and token values in function?
Yes, i'll record a video to you
Try console logging the values of email and token
I did
please create a minimal github repo

Are you sure there isn't some space around the token? In your function try this
token: token.trim(),same thing

Email: yassinmashaly55@gmail.com | OTP: 659488
.
Also just to be sure these are previous logs right? because in the video otp you entered is different
Yes
Problem solved, there was a conflict in my side!
Thanks @inder
happy to hear you got it working!