Smack's connection to Google XMPP service (gtalk) throws "SASLError using PLAIN: not-authorized"
I am trying to connect to gmail using the SMACK API but I am getting the following error and I have been stuck for the last two days.
Exception in thread "main" org.jivesoftware.smack.sasl.SASLErrorException: SASLError using PLAIN: not-authorized
at org.jivesoftware.smack.SASLAuthentication.authenticate(SASLAuthentication.java:348)
at org.jivesoftware.smack.tcp.XMPPTCPConnection.login(XMPPTCPConnection.java:244)
at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:442)
I am using smack 4.0.3 jars and Java 7. gmail is not blocked on my office network. I am tired of all the suggestions offered in the forums.
1. setting SASLMechanism to PLAIN / DIGEST-MD5.
2. adding the Thread.sleep delay after connect.
3. by setting the dummy SSLSocketFactory.
4. removing the domain name from user name.
Below is the code I am trying to follow.
public class JabberExample {
public static void main(String[] args) throws Exception{
XMPPTCPConnection con = new XMPPTCPConnection("gmail.com");
SASLAuthentication.supportSASLMechanism("PLAIN",0);
con.connect();
con.login("username", "password");
Chat chat = ChatManager.getInstanceFor(con).createChat("chatusernam@gmail.com", new MessageListener() {
public void processMessage(Chat chat, Message message) {
System.out.println("Received message: " + message);
}
});
chat.sendMessage("Message..!!");
con.disconnect();
}
}
Hope I have suggestions and help.
+3
source to share
1 answer
Google recently switched to the inability to use PLAIN and similar methods in their accounts - https://support.google.com/accounts/answer/6010255 .
If you want to use such auth mechanisms, your account will need to enable them - https://www.google.com/settings/security/lesssecureapps
+10
source to share