Manually generating a link
You can use our backend SDK to generate magic links as shown below:
- NodeJS
- GoLang
- Python
- Other Frameworks
Important
For other backend frameworks, you can follow our guide on how to spin up a separate server configured with the SuperTokens backend SDK to authenticate requests and issue session tokens.
import Passwordless from "supertokens-node/recipe/passwordless";
async function createMagicLink(email: string) {
const magicLink = await Passwordless.createMagicLink({email, tenantId: "public"});
console.log(magicLink);
}
import (
"fmt"
"github.com/supertokens/supertokens-golang/recipe/passwordless"
)
func main() {
email := "..."
tenantId := "public"
magicLink, err := passwordless.CreateMagicLinkByEmail(tenantId, email)
if err != nil {
// handle error
}
fmt.Println(magicLink)
}
- Asyncio
- Syncio
from supertokens_python.recipe.passwordless.asyncio import create_magic_link
async def create_link(email: str):
magic_link = await create_magic_link("public", email, phone_number=None)
print(magic_link)
from supertokens_python.recipe.passwordless.syncio import create_magic_link
def create_link(email: str):
magic_link = create_magic_link("public", email, phone_number=None)
print(magic_link)
Multi Tenancy
Notice that we pass in the "public"
tenantId to the function call above - which is the default tenantId.
If you are using our multi tenancy feature, you can pass in another tenantId which will be embedded in the link by SuperTokens. This will ensure that when the user clicks on the link and signs up, they sign up to the tenant you want to give them access to.
Note that the generated link will use the configured websiteDomain
from the appInfo
object (in supertokens.init
), however, you can change the domain of the generated link to match that of the tenant ID.