2FA getting error generating totp uri

I have 2fa enable, and when i trying to sign in, i'm getting error generating totp uri. I'm getting 401 Unauthorized. I double checked the password. I'm using sveltekit. here the snippet i used directly for docs
const { data, error } = await authClient.twoFactor.getTotpUri({ password: "password" // user password required })
const { data, error } = await authClient.twoFactor.getTotpUri({ password: "password" // user password required })
Can someone please explain or help why im getting this error
2 Replies
Soheel
Soheel4mo ago
Afaik you need to first log the user in to call this route, so first signIn and then getTotpUri
misterh
misterhOP4mo ago
Since I have 2fa turn on. It's wont allow sign in right?
await authClient.signIn.email({
email: "user@example.com",
password: "password123",
}, {
async onSuccess(context) {
if (context.data.twoFactorRedirect) {
// Handle the 2FA verification in place
}
}
}
})
await authClient.signIn.email({
email: "user@example.com",
password: "password123",
}, {
async onSuccess(context) {
if (context.data.twoFactorRedirect) {
// Handle the 2FA verification in place
}
}
}
})
So how do I ignore two factor redirect. Since I'm required 2fa verification, it won't generate the session. Is there any workaround this? Opt email verification work. But I'm only having problem generating totp uri

Did you find this page helpful?