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

1 Answer 1


I solved it running this command below:

n98-magerun2.phar msp:security:tfa:reset myadminuser 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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