2FA Error

await authClient.twoFactor.verifyTotp({
code: "" // user input
})
await authClient.twoFactor.verifyTotp({
code: "" // user input
})
so im following the docs, i called twoFactor enable, it successfully generated totpURI and backcodes, Im also able to scan the code using google authenticator. but then im trying to verify the code. i get invalid two factor cookie. I'm also getting 401 unauthorized. What the problem or if im doing something wrong
4 Replies
Baldy
Baldy4mo ago
i got same issue, when i put wrong code it return invalid two factor cookie but if the 6char code is correct it return success
Baldy
Baldy4mo ago
No description
Baldy
Baldy4mo ago
and this if i put wrong code
No description
misterh
misterhOP4mo ago
Did your code generate better-auth.twofactor cookie on enable? Can I show your code please Bruh This error only happen when you override the default period time for totp Finally solved it by sticking with default period and removing totpOption override

Did you find this page helpful?