back arrowBack to Identipedia

What Are Magic Links and How Do They Work?

What are magic links and how do they work?


“Science is magic that works.” - Kurt Vonnegut. 

In the digital age, the quest for secure yet convenient user authentication methods is more crucial than ever. Enters magic link authentication – a simple, user-friendly authentication form that's been rapidly gaining popularity among apps seeking to enhance user experience without compromising security.

But what exactly are magic links and how do they work? Let’s explain this magic trick and see if this is the right authentication method for your application.

What is a magic link?

Magic links are a passwordless authentication method using URLs with unique and time-limited embedded tokens to verify a user’s identity during the login process. These links are typically emailed to the users, but can also be sent via SMS or other messaging platforms like WhatsApp. All the user needs to do is click or tap the link to be authenticated and logged in to the application or service they’re trying to access.

If implemented correctly, magic link authentication greatly improves the user experience, reduces churn due to forgotten passwords, and increases app conversions. Users find magic links familiar because they have already interacted with similar (although much unhappier) flows whenever they reset their password. 

They also work similarly to one-time passwords (OTP), except they are links instead of numeric PINs.

Magic links work by embedding a token within the link's URL that is unique and time-limited. This token is associated with the user's account and is verified by the server when the link is accessed. Once the server confirms the token is valid and has not expired, the user is authenticated.

Here is what users see when they go through magic link authentication:

  1. The user enters their email address in the app login page.

  2. The user gets an email with a link.

  3. Once the user clicks the link, they are logged in.

The simplicity of the steps above is probably how the “magic” moniker arose. But to make the magic happen, a few other things are happening under the hood. Here’s how magic links work in some more detail:

How magic links work
Fig: How magic link authentication works
  1. The user enters their email address in the application login page.

  2. The email address is checked against the database to check if a registered user is trying to log in.

  3. The application generates a token and embeds it in a magic link. The token is also stored for later validation.

  4. The application sends the user an email with the link. Additional parameters can be added to the link, such as expiry time and session limits.

  5. When the user clicks the link, the application checks the token.

  6. The user is logged in.

If the steps above sound familiar, it’s because something very similar happens during password reset flows. While password reset links send users to a page to create a new password, magic links grant users one-time account access. 

In recent years, magic link authentication has been adopted by many applications, including prominent examples like Medium and Slack.

Example of magic link authentication used by Medium
Fig: Example of magic link authentication used by Medium

Magic links make the lives of users, developers, and product owners easier. 

Simplicity for Users

Users only need to access their email and click on a link, no need to remember passwords.

Enhanced Security

Dynamically generated with a short expiration window, reducing the opportunity for attacks.

Reduced Password Fatigue

Eliminates the need for users to remember multiple passwords, reducing password fatigue.

Decreased Risk of Phishing

Direct communication via email reduces susceptibility to phishing compared to traditional passwords.

Lower Password Reset Requests

Significant reduction in password reset requests, lowering support workload.

Improved User Experience

Streamlines the login process, enhancing overall satisfaction.

Reduced Development Complexity

May require less infrastructure and development effort than secure password systems.

Cutting Down on Password-Related Vulnerabilities

Mitigates risks associated with weak or reused passwords.

End users

  • Fast and seamless login experience. Users just need to enter their email address to log in to the application. There are also no hardware dependencies to use magic links, unlike some forms of possession-based and biometric authentication. Here, the email account is the “something only you have” for users.

  • Avoiding password pain: Users avoid the challenges and bad behaviors driven by passwords. There's no need for them to generate, memorize, or keep track of another password. This means they can avoid the cumbersome process of resetting their password — a common frustration when they inevitably forget it. Additionally, by not reusing passwords, they decrease the risk of their accounts being compromised in the event that a password is exposed due to a data breach in another application.

Developers and IT teams

  • Easy deployment: Since magic links follow a similar flow to password resets, implementing them usually only takes some minor code adjustments. Frameworks like Rails have also started including this functionality out of the box, further simplifying deployment.

  • Fewer support tickets: Support and help desk teams will no longer have to deal with the large volume of password-related support tickets. Magic links will also help reduce failed login alerts for the security team, especially false positives.

  • Reduced attack surface: With magic links, applications can free up infrastructure otherwise dedicated to encrypting, managing, and storing passwords. This also reduces the attack surface by making databases less attractive targets for adversaries. 

Product and business owners

  • Reduce user churn: The login process is usually fraught with user friction, leading to churn and lost revenue. Magic links remove friction and can actually make the login experience an enjoyable one, increasing the likelihood of repeat user visits.

  • Increase conversions: Magic link authentication can help marketing and growth teams by reducing the number of abandoned cart transactions due to forgotten passwords. They can also be embedded in marketing emails and text messages, making them useful for sending reminders, discounts, and product updates. 

While magic links solve a lot of existing problems with password-based authentication, they bring some risks of their own.

  • Only as secure as the user’s email address: In theory, the user should be the only person with access to their email account. However, email accounts continue to be prime targets for phishing and credential stuffing attacks. An attacker who gains access to a victim's email account can use magic links to access other applications fraudulently.

  • Less admin oversight: Admins don’t have any visibility into the email account of the user. Thus, they cannot be sure if other people can also access the user’s email. If the user’s device is lost or stolen, bad actors can get access to their email and magic links.

  • Depends on the email service: Applications using magic links work with an email delivery service and are dependent on the reliability and performance of that service. Missed emails – or emails that go to spam folders – cause a bad user experience and can lead to drop-off.

  • Susceptible to some attacks: Although magic links remove many password-related woes, they also come with a few chinks in their armor. They are vulnerable to man-in-the-middle (MITM) attacks if users are on an unencrypted network, since attackers can steal the token and gain fraudulent access. As mentioned earlier, magic links can also be phished “by proxy”, since access to the email account can be phished. 

While magic link authentication has many use cases, it is not a one-size-fits-all approach. Here are some situations where magic links are a good candidate:

  • When user login is infrequent: Magic links are usually provided at the beginning of a user session and grant single-use access. This form of authentication is ideal when the user needs to log in only once or infrequently e.g. mobile apps, email accounts, and workforce collaboration apps like Slack. 

  • When user account creation is a priority: Magic links remove friction from the user login process, which is usually a large source of churn. For organizations that are focused on getting as many users into the application as seamlessly as possible, magic links are a good option.

  • When another form of authentication is also present: As covered earlier, magic links are not immune to security risks if used on their own. However, pairing them with other forms of authentication such as passkeys or OTP reduces the likelihood and impact of these links being phished or compromised. Using magic links in a multi-factor authentication (MFA) flow enhances security while still providing a good user experience.

Read more: A Guide to User Authentication Methods 

It’s clear that businesses that adopt magic link authentication can benefit from increased user satisfaction and trust, while also strengthening their security posture.

In case you’re worried that adding, updating, and modifying magic links in your application's authentication flow would be time-consuming and costly – Descope makes it very easy for developers to add and customize magic links with the help of a drag-and-drop workflow editor, SDKs, and APIs.

Fig: Drag-and-drop magic links with Descope
Drag-and-drop magic link authentication with Descope

Sign up for a Free Forever account to include magic links in your authentication flow today. Have questions about magic link implementation with Descope? Book time with our auth experts.