要验证使用的authToken谷歌对话(XMPP,啪)authToken、XMPP

2023-09-12 07:47:07 作者:兴你一世烟花

该应用程序我写的连接到XMPP服务器,如果用户选择,我想给他们连接到他们的谷歌聊天账户的选项,而无需输入凭据...

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...

要做到这一点,我会得到使用谷歌帐户,获得令牌和验证到Google Talk允许(XMPP服务器,使用啪),使用令牌。

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..

现在的问题是..我该怎么做呢?我的意思是,我怎么验证到GTalk的服务器,如果我知道的登录名和令牌?

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?

任何想法,见解? :) 如果不是这样,也许有人知道我在哪里能找到有人知道? (谷歌联系人,任何人:P)

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

推荐答案

您正在寻找在X-GOOGLE-TOKEN SASL机制的文件。 这的应该开始。使用服务=邮箱:

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

这将返回 200 OK 和三个值:

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

(其中,\ 0意在与零值的单个八位字节)。在最初的SASL身份验证使用这样的:

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