Smack 4.1 connection to gtalk -
Smack 4.1 connection to gtalk -
i updated smack 4.1, cannot connect gtalk. code using:
xmpptcpconnectionconfiguration.builder configbuilder = xmpptcpconnectionconfiguration.builder(); configbuilder.sethost("talk.google.com"); configbuilder.setport(5222); configbuilder.setservicename("gmail.com"); configbuilder.setsecuritymode(securitymode.required); configbuilder.setdebuggerenabled(true); configbuilder.setsendpresence(true); configbuilder.setusernameandpassword(pref.getstring(constants.key_user, ""), pref.getstring(constants.key_token, "")); saslauthentication.blacklistsaslmechanism(saslmechanism.plain); abstractxmppconnection connection = new xmpptcpconnection(configbuilder.build()); seek { connection.connect(); connection.login();//.login(pref.getstring(constants.key_user, ""), pref.getstring(constants.key_token, "")); } catch(exception e) { e.printstacktrace(); homecoming null; }
this error get:
d/smack(12807): sent (3): <auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='x-oauth2'>removed_this=</auth> d/smack(12807): recv (3): <failure xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><incorrect-encoding/></failure>
the problem line in saslxoauth2mechanism:
base64.encode(tobytes('\u0000' + authenticationid + '\u0000' + password));
as quick test replace in code
abstractxmppconnection connection = new xmpptcpconnection(configbuilder.build());
with this
abstractxmppconnection connection = new xmpptcpconnection(configbuilder.build()) { @override public void send(plainstreamelement auth) throws notconnectedexception { if(auth instanceof authmechanism) { final xmlstringbuilder xml = new xmlstringbuilder(); xml.halfopenelement(authmechanism.element) .xmlnsattribute(saslstreamelements.namespace) .attribute("mechanism", "x-oauth2") .attribute("auth:service", "oauth2") .attribute("xmlns:auth", "http://www.google.com/talk/protocol/auth") .rightanglebracket() .optappend(base64.encodetostring(stringutils.tobytes("\0" + authenticationid + "\0" + password))) .closeelement(authmechanism.element); super.send(new plainstreamelement() { @override public string toxml() { homecoming xml.tostring(); } }); } else super.send(auth); } };
i didn't test it, hope works. authenticationid , token credentials.
smack
Comments
Post a Comment