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 ThirdPartyPasswordless from "supertokens-node/recipe/thirdpartypasswordless";
async function createMagicLink(email: string) {
const magicLink = await ThirdPartyPasswordless.createMagicLink({email, tenantId: "public"});
console.log(magicLink);
}
import (
"fmt"
"github.com/supertokens/supertokens-golang/recipe/thirdpartypasswordless"
)
func main() {
email := "..."
tenantId := "public"
magicLink, err := thirdpartypasswordless.CreateMagicLinkByEmail(tenantId, email)
if err != nil {
// handle error
}
fmt.Println(magicLink)
}
- Asyncio
- Syncio
from supertokens_python.recipe.thirdpartypasswordless.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.thirdpartypasswordless.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.