Friday 5 October 2018

Gmail API and Python - Resolved - SMTPAuthenticationError (534, '5.7.14') using Gmail API and Python

While working on Gmail API and integrating it in a project using Python, I came across this error "SMTPAuthenticationError (534, '5.7.14')" whose solution was not so obvious. I found many people facing the same problem on different forums so I ended up writing a post for future reference. The exact error was:

"(534, '5.7.14 <\n5.7.14 ....
> Please log in via\n5.7.14 your web browser and then try again.\n5.7.14  Learn more at\n5.7.14 g65-v6sm13547202pfg.98 - gsmtp')"

You need to check and verify following things:

Recheck your username and password (I know its obvious but still you might be making some mistake while entering the password)

Check if you have enabled less secure apps by navigating to:

STEP 3 (Important):
Disabling Captcha for your Client App which is accessing the Gmail API. Using your browser, login to your Gmail Account and navigate to the link:

Click the continue button. You will see the following message:
"Account access enabled Please try signing in to your Google account again from your new device or application."

Its been found that google resets this setting of UnlockCaptcha if there are any changes in the Gmail Account Settings and therefore the error SMTPAuthenticationError (534, '5.7.14') occurs. You need to go through STEP 3 again so that your App can access Gmail API and send mail.