I don't use gmail, but does Google require app password now instead of account password, as Yahoo, Outlook, etc nowadays? And if so, are you generating and using an app password and still getting the error?
FWIW I'm trying to open the BlackBerry Knowledge Base web site to look something up, and the site isn't opening for me. What I recall is a list of things to check. For instance, logging into email on the website and doing the captcha. There may also be a setting at Google two allow less secure connection methods. Anyway, suggest looking for articles on gmail at the Knowledge Base if it will open for you.
EDIT: This isn't the article I was thinking of, but see the following. It is specific to the error you observe. I suspect the issue is two-step verification.