title: SMTPAuthenticationError 5.7.14 Please log\n5.7.14 in via your web browser
body: <p>I have a script which sends periodically reports to a list of recipients. Everything worked fine until today 4 am, when I checked my inbox and the reports didn't come.</p>
  <p>By debugging the code:</p>
  <pre><code>import smtplib
  username=&quot;my.user.account@gmail.com&quot;
  password=&quot;my.correct.password&quot;
  
  server=smtplib.SMTP('smtp.gmail.com',587)
  server.ehlo()
  server.starttls() 
  server.ehlo()
  server.login(username,password)
  
  #if login worked, it should send a message, but it is not working, so I will suppress this part
  
  server.quit()
  </code></pre>
  <p>I receive the following (old known) result:</p>
  <blockquote>
  <p>(250, b'smtp.gmail.com at your service, [SERVERIP]\nSIZE
  35882577\n8BITMIME\nSTARTTLS\nENHANCEDSTATUSCODES\nPIPELINING\nCHUNKING\nSMTPUTF8')
  (220, b'2.0.0 Ready to start TLS') (250, b'smtp.gmail.com at your
  service, [SERVERIP]\nSIZE 35882577\n8BITMIME\nAUTH LOGIN PLAIN XOAUTH2
  PLAIN-CLIENTTOKEN OAUTHBEARER
  XOAUTH\nENHANCEDSTATUSCODES\nPIPELINING\nCHUNKING\nSMTPUTF8')
  Traceback (most recent call last):   File &quot;&lt;pyshell#52&gt;&quot;, line 6, in
  
  server.login(username,password)   File &quot;C:\Python\Python36\lib\smtplib.py&quot;, line 729, in login
  raise last_exception   File &quot;C:\Python\Python36\lib\smtplib.py&quot;, line 720, in login
  initial_response_ok=initial_response_ok)   File &quot;C:\Python\Python36\lib\smtplib.py&quot;, line 641, in auth
  raise SMTPAuthenticationError(code, resp) smtplib.SMTPAuthenticationError: (534, b'5.7.14
  &lt;https://accounts.google.com/signin/continue?sarp=1&amp;scc=1&amp;plt=AKgnsbu5\n5.7.14
  wJL_YP3XLTGPzP_UBwtyCHhzHE1y1G8R0iHaz_pxG9fBH4CePmbXuAE1qH8HvnXTgqcmKi\n5.7.14
  P23_lJoZX_pfbNUOxQp4Fr2VhgbAjnlu3ZL_pcjVBd-TTMUVCAah6Q2-Vq5Dffm9s4UWwl\n5.7.14
  J7V7CjE06eHkw1IlphV4lLbRKVp9Hk7vC92zLQ5zM27cbQiTM8W3lEgm&gt; Please
  log\n5.7.14 in via your web browser and then try again.\n5.7.14  Learn
  more at\n5.7.14  <a href="https://support.google.com/mail/answer/78754" rel="noreferrer">https://support.google.com/mail/answer/78754</a>
  r131sm2964505vkr.40 - gsmtp')</p>
  </blockquote>
  <p><strong>Things I've tried</strong></p>
  <p><em>Allow less secure apps</em> (as indicated in <a href="https://www.google.com/settings/security/lesssecureapps" rel="noreferrer">https://www.google.com/settings/security/lesssecureapps</a>): This flag was set to true since I created the account.</p>
  <p><em>Disable Captcha</em> (as indicated in <a href="https://accounts.google.com/DisplayUnlockCaptcha" rel="noreferrer">https://accounts.google.com/DisplayUnlockCaptcha</a>): Visited this URL several times. No luck.</p>
  <p><em>Login via browser</em>: It works fine, when logging via any Internet Browser from any computer, although in the first times I had to insert a code sent to the account's recovery phone.</p>
  <p>I came across other things I could try, but I am not sure it could work:</p>
  <ul>
  <li>Specific app passwords</li>
  <li>Oauth2</li>
  <li>Change or reset password</li>
  </ul>
  <p>I will probably try oauth2, however it would require a change in my code, which I want to avoid due to some restrictions in the server.</p>