A way to get a reset password link in B2B

Hi all,

What would be the best way to get a reset password link in B2B? Say, my user forgot their password and wants to reset it.

Thanks,
Udi

Hey Udi – thanks for posting!

I think the Password reset email start endpoint is probably what you’re looking for.

That endpoint will send an email to the user’s email address with a “Reset password” button. When they click the button, they’ll be redirected back to your application with a token that they can use to reset their password via the Password email reset endpoint.

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

Thanks Nicole! I think this exactly what I’m looking for!!

1 Like

Hey Nicole,

I’m getting strange errors when I try this. The error complains I need to have a redirect-url - I do have one set up. Regardless, I’m not sure I understand why that’s needed for the purpose of a password reset? so I’m completely unsure what I need to do to make this work. I would be grateful for any advice on how to make this work.

Thanks,
Udi

This is what I’m running

client = B2BClient(
    project_id="...",
    secret="...",
)

resp = client.passwords.email.reset_start(
    organization_id="...",
    email_address="...",
)

and this is what I’m getting

StytchError: status_code=400 request_id=‘request-id-test-3fe36fb5-2054-46ed-8a34-ad7421ad8074’ error_type=‘no_login_redirect_url’ error_message=‘There are no login redirect URLs registered. To set login redirect URLs for this project please visit Stytch - User infrastructure + passwordless authentication. For more information on why this validation is necessary please visit stytch.com/docs/api/url-validation.’ error_url=‘Authentication API reference - errors | Stytch’ original_json={‘status_code’: 400, ‘request_id’: ‘request-id-test-3fe36fb5-2054-46ed-8a34-ad7421ad8074’, ‘error_type’: ‘no_login_redirect_url’, ‘error_message’: ‘There are no login redirect URLs registered. To set login redirect URLs for this project please visit Stytch - User infrastructure + passwordless authentication. For more information on why this validation is necessary please visit stytch.com/docs/api/url-validation.’, ‘error_url’: ‘Authentication API reference - errors | Stytch’}

Heya Udi, our password reset emails also include a link to login without resetting your password; a smoother path to sign in for a lot of users. You can check out what they look like in the Email editor in the Dashboard: https://stytch.com/dashboard/templates

So when you send off a password reset email, you’ll need a login_redirect_url set on your Project.

Hey Chris,

Thanks for the very quick response! I see what the issue was - while I did set a login_redirect_url in the project, I didn’t do this on the default project. Once I did that it works. Thanks for the help!

Awesome! Glad we got it fixed quickly.