简体   繁体   中英

Authenticate to Google Talk (XMPP, Smack) using an authToken

The app I'm writing is connecting to a XMPP server, and if the user chooses, I want to give them the option to connect to their google chat account, without having to enter the credentials...

To do this, I'd get the permission to use the google account, get the token and authenticate to google talk (XMPP server, using Smack) using the token..

The problem is.. how do I do that? I mean, how do I authenticate to the GTalk server if I know the login and the token?

Any ideas, insights? :)
If not, maybe anyone knows where could I find someone that knows? (Google contacts, anyone? :P )

You're looking for documentation on the X-GOOGLE-TOKEN SASL mechanism. This should be the beginning. Use service=mail:

https://www.google.com/accounts/ClientLogin?
    accountType=GOOGLE&
    Email=YOURUSERNAME@gmail.com&
    Passwd=YOURPASSWORD&
    service=mail

Which will return 200 OK and three values:

SID=<long string>
LSID=<long string>
Auth=<long string>

Parse out the Auth string, then construct a string with this form:

jidAndToken ="\0" + UTF8(YOURUSERNAME@gmail.com) + "\0" + Auth

(where "\0" is intended to be a single octet with value zero). Use this in the initial SASL auth:

<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' 
      mechanism='X-GOOGLE-TOKEN'>Base64(jidAndToken)</auth>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM