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

前端 未结 1 1505
难免孤独
难免孤独 2020-12-03 09:37

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

相关标签:
1条回答
  • 2020-12-03 09:47

    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>
    
    0 讨论(0)
提交回复
热议问题