title: connect to SMTP using Oauth2 Gmail
body: <p>I am trying to connect SMTP using the Oauth2 for Gmail , but getting the following issues.</p>
  
  <p><strong>Oauth token and email name</strong> are correct and works to connect IMAP. </p>
  
  <p>I am following the <a href="http://code.google.com/p/google-mail-oauth2-tools/source/browse/trunk/java/com/google/code/samples/oauth2/OAuth2Authenticator.java?r=3" rel="nofollow">example of google</a>.</p>
  
  <pre><code>DEBUG SMTP: Authenticate with SASL
  DEBUG SMTP: SASL mechanisms allowed: XOAUTH2
  DEBUG SMTP: SASL AUTH command trace suppressed
  DEBUG SMTP SASL: Mechanisms: XOAUTH2
  DEBUG SMTP SASL: No SASL support
  DEBUG SMTP: SASL authentication failed
  DEBUG SMTP: Attempt to authenticate
  DEBUG SMTP: check mechanisms: LOGIN PLAIN DIGEST-MD5 NTLM 
  DEBUG SMTP: AUTH LOGIN command trace suppressed
  DEBUG SMTP: AUTH LOGIN failed
  
  
  javax.mail.AuthenticationFailedException: 535-5.7.1 Username and Password not accepted. Learn more at
  535 5.7.1 http://support.google.com/mail/bin/answer.py?answer=14257 ol4sm17455809pbb.58
  </code></pre>