Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
283 views
in Technique[技术] by (71.8m points)

android - 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 )

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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 protected]&
    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 ="" + UTF8([email protected]) + "" + Auth

(where "" 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>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...