Yes - that error from gmail is not an authentication failure. It’s asking you to login from a web browser because it think something fishy is going on with the account.
By turning on 2FA you’ve done what gmail was asking - you logged in via a browser.
Are you also using it to send emails?