© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•4y ago•
34 replies
xzilja

Issues setting up OTP code signin and signup flows

I'm trying to create a user flow where an OTP code is sent to users email and then verified to sign them in.

Following supabases documentation I am doing following

1. I changed from using link in "Magic Link" email template to
{{ .Token }}
{{ .Token }}

2. I tried using both
type: 'magiclink'
type: 'magiclink'
and
type: 'signup'
type: 'signup'
in code below
3. My email provider settings are set to
60000
60000
for expiry seconds and
6
6
for password length. Email confirmation is set to be enabled.

Implementation is as follows

const { data, error } = await supabaseClient.auth.signInWithOtp({ email })
// {"data": {"session": null, "user": null}, "error": null}

const { data, error } = await supabaseClient.auth.verifyOtp({ email, token, type: 'signup' })
// {"data": {"session": null, "user": null}, "error": [AuthApiError: Token has expired or is invalid]}
const { data, error } = await supabaseClient.auth.signInWithOtp({ email })
// {"data": {"session": null, "user": null}, "error": null}

const { data, error } = await supabaseClient.auth.verifyOtp({ email, token, type: 'signup' })
// {"data": {"session": null, "user": null}, "error": [AuthApiError: Token has expired or is invalid]}


I double verified that token I am sending is exact one as I got in email, yet I keep getting that auth error.
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

auth.signUp and auth.signIn gives same otp every time and fail to verifyOtp
SupabaseSSupabase / help-and-questions
3y ago
cannot signin after signup
SupabaseSSupabase / help-and-questions
13mo ago
OTP via email for signIn
SupabaseSSupabase / help-and-questions
4y ago
Cannot signin/signup 401 unauthorized
SupabaseSSupabase / help-and-questions
3y ago