Connect to Google Talk using smack

Viewed 6107

I want to develop a Java application which connects to Google Talk and allows a user to chat with it's friends. I am using smack API and the fallowing code:

ConnectionConfiguration config = new ConnectionConfiguration("talk.google.com",5222,"gmail.com");
SASLAuthentication.supportSASLMechanism("PLAIN", 0);
XMPPConnection connection  = new XMPPConnection(config);
try {
    connection.connect();
} catch (XMPPException e) {
    e.printStackTrace();
}
try {
    connection.login("username", "password");
} catch (XMPPException e) {
    e.printStackTrace();
}

but I obtain the fallowing exception:

SASL authentication PLAIN failed: invalid-authzid: 
    at org.jivesoftware.smack.SASLAuthentication.authenticate(SASLAuthentication.java:337)
    at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:203)
    at org.jivesoftware.smack.Connection.login(Connection.java:348)
    at Main.main(Main.java:21)

Can someone help me to solve this problem?

3 Answers
Related