I am encoutering the more factors error even though I am providing proper mfa code in the workflow.
The following happens:
- User provides email adress
- User receives the email with the proper callback link and secret
- User gets authenticated and is prompted to provide mfa code (also via email)
- 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
@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:
- ✅
account.createMagicURLSession()(user gets link) - ✅ User clicks link →
account.updateMagicURLSession()— success - ✅ Appwrite triggers MFA → sends 6-digit email code
- ❌
account.updateMfaChallenge()is called with the code - 🔴 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
- 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');
- 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
challengeIdif applicable (depending on your version of Appwrite SDK).
- The challenge from
- 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).
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();
Appreciate the answers. I have gone through the steps now and implemented both the session checks and restore as well as to call account before the challenge. It does not work. I will try to produce a simple example app that I can share for reproduction.
That would really help @blackfan23 Thanks :appwritepeepo:
I have now put together a flow that combines MFA and Magic URL. Same error. It's a basic Angular app with no fancy business logic. Vibe coded the basics, so don't be distracted by some of the code. However, the authorisation flow is handcrafted and is the same one that I use in production. Repo here
env variables go under /src/environments. The example file is included.
Hi, Just reviwed. Looks fine to me. You did everything on point. I attached a pdf with the updated solutions mainly dealing with time delays to session update and url creation. since there is microseconds delay with appwrite communication and session updated. Have a look please.
You do not need manual collections for: users sessions mfa_verifications These are managed internally by Appwrite via the account and users APIs. Until you need them for analytics or preferences.
Recommended threads
- Realtime api and labels as permission
in my tables i set labels as permission and real-time capabilities stopped working. Before when i was having "any" role everything was working. Note: user have...
- Register Disable
this is possible disable register but keep oauth login?
- "Restore project" button fails: "Invalid...
In the dashboard, it clicking "Restore project" fails. The request sent to `PATCH https://cloud.appwrite.io/v1/projects/:project_id` with payload `{status: "act...