Skip to content
Back

Encountering More factors are required when combining magic url and mfa

  • 0
  • Self Hosted
  • Auth
  • Web
blackfan23
24 Jun, 2025, 04:27

I am encoutering the more factors error even though I am providing proper mfa code in the workflow.

The following happens:

  1. User provides email adress
  2. User receives the email with the proper callback link and secret
  3. User gets authenticated and is prompted to provide mfa code (also via email)
  4. User provides the mfa code and instead of being logged in the mfa component errors requesting more factors

What works: a) Magic URL with disabled mfa b) Email/Password with or without mfa (same mfa component/code as for the magic url). Here the code is send in the same way and upon providing it the user is properly logged in.

Since all parts are working individually or in a different context/combination I am at a loss at what more to try. Help is greatly appreciated.

As this is proprietary code I have no reproduction at hand, but can make one if that makes a different

password is using: account.createEmailPasswordSession

magic is using: account.updateMagicURLSession

mfa is using: account.updateMfaChallenge

TL;DR
Developers are encountering a "More factors required" error when combining Magic URL and MFA. The issue might be due to not fully attaching the session token or updating the session context before calling updateMfaChallenge. To fix this, ensure the token/session from updateMagicURLSession is set correctly. This error occurs even though the MFA code is provided correctly. The proposed debugging strategy includes logging the session and response, confirming only one MFA factor is required, and verifying the MFA challenge is attached to the session.
ɹǝpoƆʎɹᗡʎllıS
24 Jun, 2025, 04:49

@blackfan23 you're clearly following the correct flow, and it's helpful that MFA works with password sessions but fails specifically when used with Magic URL + MFA. Let's walk through what’s likely happening and what to check.

From your steps:

  1. account.createMagicURLSession() (user gets link)
  2. ✅ User clicks link → account.updateMagicURLSession() — success
  3. ✅ Appwrite triggers MFA → sends 6-digit email code
  4. account.updateMfaChallenge() is called with the code
  5. 🔴 Error: "More factors required" (even though you just provided the only expected factor)

What Might Be Going Wrong

✅ You're probably authenticating the Magic URL session but not fully attaching the session token or not updating the session context before calling updateMfaChallenge.

Appwrite uses cookies/tokens to associate the current session context with the MFA challenge. When using magic links, the updateMagicURLSession returns a session object that includes a userId and likely a cookie-based session (if running in browser), or token if using custom headers.

If updateMfaChallenge() is being called:

  • Outside of the same session context (e.g. missing token or cookie)
  • Or before Appwrite associates the magic link with the MFA challenge properly

…it may treat it as an incomplete session and return the "more factors required" error.

Fix Checklist

  1. Ensure token/session from updateMagicURLSession() is set
    • If using Web SDK: make sure cookies are preserved (i.e., not calling via API manually)
    • If using SSR/Node or custom flow: store the session token and reattach it to the client using: account.updateSession('SESSION_ID');
ɹǝpoƆʎɹᗡʎllıS
24 Jun, 2025, 04:49
  1. Verify that MFA challenge is being attached to that session
    • The challenge from account.createMfaChallenge() needs to be consumed in the same session that was just authenticated from the magic link.
    • You may need to store and reuse the returned challengeId if applicable (depending on your version of Appwrite SDK).
ɹǝpoƆʎɹᗡʎllıS
24 Jun, 2025, 04:50
  1. Confirm that only 1 MFA factor is required
    • Sometimes the error "More factors required" actually means "this factor wasn't enough" — double-check in the Appwrite console that your project has only 1 MFA factor required (e.g., just email, not email + TOTP).
ɹǝpoƆʎɹᗡʎllıS
24 Jun, 2025, 04:50

Suggested Debugging Strategy

To isolate the issue:

  • Log the session after updateMagicURLSession()
  • Log the response of createMfaChallenge()

Try manually calling get() right before updateMfaChallenge() to confirm you're authenticated: const session = await account.get();

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more