Frontend SDK magic link send only?

Hi there,
Newbie to Stytch here so please forgive me if this is something straight-forward, but I couldn’t see how to get this to work.
I’m using the Stytch frontend SDK to use the login form using the email magic link (from the stytch-javascript-example). However, I don’t want it to create new users, only send out the magic link if the user has only been created.

In my project dashboard under Configuration > Frontend SDKs > Authentication Products, I have set the Enabled Email Magic Link Flows to only be Send and unchecked LoginOrCreate. However, when I enter an email in the login form, it gives me a 401 endpoint_not_authorized_for_sdk.

Is there some config that I’m missing to go through the Send flow instead of the LoginOrCreate?

Thanks!

1 Like

Hey Chris – thanks for posting!

When using our Consumer pre-built UI components, it isn’t currently possible to disable signups. Sorry about that! I’ll add a +1 on your behalf to an internal feature request that we have open for this.

In this case, we generally recommend using our headless frontend JavaScript methods with your own UI. You can use our Email Magic Link send or OTP email send methods to create a login-only experience, as those endpoints will error if there isn’t yet a Stytch User associated with the provided email address.

Happy to help with any additional questions you have about this!

1 Like

Thanks Nicole!
I figured as much and have created my own login form using the email magic link send endpoint.
One question about this magi link though is that after clicking on the link, do i have to have a handler that authenticates the token in order for the session to be created?
Currently, in my callback, when I do a stytch.session.getSync() after clicking on the link, the session is still null?

Thanks!

Chris Chan

One question about this magi link though is that after clicking on the link, do i have to have a handler that authenticates the token in order for the session to be created?

Yep, this is exactly right! Once the user is redirected back to your application, you’ll need to grab the Magic Link token from the URL query parameters and use it to call the Magic Links Authenticate method. At that point, a session will be created.

Let me know if that doesn’t work for whatever reason!

1 Like