title: How to authenticate to Google Talk with AccountManager's authentication token using Smack API?
body: <p>This question is similar to: <a href="https://stackoverflow.com/questions/6194899/authenticate-to-google-talk-xmpp-smack-using-an-authtoken?answertab=oldest#tab-top">Authenticate to Google Talk (XMPP, Smack) using an authToken</a></p>
  
  <ol>
  <li><p>I have android.accounts.AccountManager class and its methods to get authentication token for Google account:</p>
  
  <pre><code>public AccountManagerFuture&lt;Bundle&gt; getAuthToken (Account account,
         String authTokenType, Bundle options, Activity activity,
         AccountManagerCallback&lt;Bundle&gt; callback, Handler handler)
  </code></pre></li>
  <li><p>I know how to prepare authentication XML:</p>
  
  <pre><code>jidAndToken ="\0" + UTF8(YOURUSERNAME@gmail.com) + "\0" + Auth
  </code></pre>
  
  <p>(where "\0" is intended to be a single octet with value zero). Use this in the initial SASL auth:</p>
  
  <pre><code>&lt;auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' 
        mechanism='X-GOOGLE-TOKEN'&gt;Base64(jidAndToken)&lt;/auth&gt;
  </code></pre></li>
  </ol>
  
  <p><br></p>
  
  <p>But I failed to integrate it with Smack API like someone did for facebook chat here: <a href="https://stackoverflow.com/questions/5317329/xmpp-with-java-asmack-library-supporting-x-facebook-platform">XMPP with Java Asmack library supporting X-FACEBOOK-PLATFORM</a></p>
  
  <p>Can someone help me?</p>