Get 'magic link' URL for a specific user

Hello,

I’m trying to sign up a user using an external website, and then redirect him back to Anvil as a logged in user.

I thought of creating an HTTP endpoint for signup, and return in the response the magic link and redirect him to it.

I could not find a way to get the magic link for a user, how do I do that?

Is there a better way to achieve my goal?

Appreciate any help,

Thanks

Do you mean you’re trying to use a third-party website via OAuth? If so, there’s a specific protocol for that. You won’t be using Anvil’s magic link for that.

If you mean something else, then I’m not sure what that is.

Not OAuth, just an external landing page with a username and password fields.

I want to get the magic link that is being sent in the email below, but I don’t know how to access it from Anvil editor to send it in the response.

The docs have this function that allows you to trigger the email from code: Anvil Docs | anvil.users

If you absolutely need to get the URL itself, you’ll probably need to build it yourself. It’s just a hash URL that executes the force_login function: Anvil Docs | anvil.users

You’ll find the answer in here: Signup_with_email() without accepting a password - #5 by socint

You can trigger the send token from an external page if you follow the logic.

I’m trying to get that link and save it to my users table, and not send the email directly.

Regarding the hash url - maybe this is the solution.
You are saying I need to create a new hash URL, with a form that will use the force login for that specific user_row, and once the user is logged in to redirect him to the home page?

Thanks, but when user the user signups in the landing page they will already provide a password. I’m trying to just save the magic_link URL for each user.

Correct. You’re basically creating your own magic link so that you have control over it.

I’m struggling by to understand the security logic of storing a persistent magic link when their purpose is to expire. (I get it if you want save the hash url to a user profile page, which is accessible to them on single factor password auth).