Create a Magic-Link from the server

The documentation for creating a Magic-Link for signing in with auth.api.signInMagicLink mentions we have to set the headers ("This endpoint requires session cookies"), but I'm not sure which headers have to be given, when I'm doing the call from the server? Basically what I'm trying to do is using the magic-link as a kind of "invite" for users, so I have some script in my backend which automatically sends the magic-link to the new user. What should be the content of that header? it says it's for cookies, but I'm not using cookies when doing a call from the backend on the behalf of another user
No description
8 Replies
The Untraceable
So when you say invite for users, you mean like inviting them for your app? Or org? There might be a better way to do this
mael
maelOP3d ago
it would mean that as an admin, I have a dashboard, where I can for instance type an email, give some permissions, and it would invite the person what better way would you suggest?
The Untraceable
https://www.better-auth-kit.com/docs/plugins/app-invite Might want to give this a shot maybe
Better Auth Kit
App Invite | Better Auth Kit
Invite users to your application and allow them to sign up.
mael
maelOP3d ago
ah nice but it's a separate proejct I had seen it but I was wary of adding an extra dependency in my code... so I was thinking to rebuild it internally, but then I thought about it and that magic-links might be already 80% of the way there, and would just require a few changes to let it work completely
The Untraceable
1 more dependency isnt that bad i dont think (i could be wrong for your use cases), imo save yourself the hassle. The plugin only depends on better auth ans zod it looks like (which I'm pretty sure is already installed with better auth), so not that much damage, but up to you as it is your project
The Untraceable
GitHub
better-auth-kit/packages/plugins/app-invite at main · ping-maxwell...
A collection of plugins, tools, libraries, examples, and more for Better-Auth. 🚀 - ping-maxwell/better-auth-kit
mael
maelOP3d ago
interesting, but they don't really say how to install / configure in their doc? is it just a plugin to add?

Did you find this page helpful?