2

My client enabled 2FA (Two-Factor Authentication) in the Magento 2 admin panel, but every time that I scan the code to have it configured in my Google Authenticator and try to enter the code, it's invalid.

I checked and it's using Google as a provider, so what I could do to be able to access the admin panel?

n98-magerun2.phar config:store:get %twofactorauth%

enabled 2FA (Two-Factor Authentication) in the Magento 2 admin panel

3 Answers 3

3

I solved it running this command below with Magerun 2:

n98-magerun2.phar msp:security:tfa:reset <YOUR_ADMIN_USER> google

But you can also run this command with Magento CLI:

php bin/magento security:tfa:reset <YOUR_ADMIN_USER> google

Then I opened the admin in a new incognito window.

If you have trouble signing in with 2FA, consider the following:

  • Some mobile apps include options to sync. This option reconnects the app and server and synchronizes the time settings on the device and server.
  • Revoking a device or resetting an authenticator can help users connect.
  • Clearing web cache and cookies for the Magento instance can also help. Authenticators, like Google, use generated cookies to save access and duration. Clear your cookies for your specific browser and Magento instance domain.
  • Blocking cookies prevents some authenticators, such as Google Authenticator, from completing the verification process. Add a rule to your browser that allows cookies for your Magento instance.

Reference: DevDocs - Managing Two-Factor Authentication

0

I was having a similar issue. Installing magneto 2.4.6 fresh and logging into the /admin would send the email to configure the authenticator, great! However scanning the QR code and entering the OTP resulted in a popup "error" with no other information, the existing answer helped me.

From the magneto install directory:

php bin/magento security:tfa:reset REPLACE_WITH_YOUR_USER_NAME google

Then as @Rafael Corrêa Gomes mentioned, clear the cache/cookies of your browser and repeat the authenticator configuration process when you try to login to the /admin area

I believe the key is to clear your cache/cookies in your browser or in my case i opened a different browser in a private window after executing the above command.

0

I case anyone are having similar issues, I resolved by going incognito mode. It seem to happen specially if you have multiple sessions open which was my in my case. I looks like some issues with browser cache/cookies.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.