Smack连接到Google';s XMPP服务(gtalk)抛出异常;SASLError使用普通:未授权“;

Smack连接到Google';s XMPP服务(gtalk)抛出异常;SASLError使用普通:未授权“;,xmpp,smack,google-talk,Xmpp,Smack,Google Talk,我正在尝试使用SMACK API连接gmail,但出现了以下错误,我在过去的两天里一直被困在这里 Exception in thread "main" org.jivesoftware.smack.sasl.SASLErrorException: SASLError using PLAIN: not-authorized at org.jivesoftware.smack.SASLAuthentication.authenticate(SASLAuthentication.java:348) a

我正在尝试使用SMACK API连接gmail,但出现了以下错误,我在过去的两天里一直被困在这里

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)
我使用的是smack 4.0.3 JAR和Java 7。gmail在我的办公室网络中没有被阻止。我已经厌倦了论坛上提出的所有建议

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. 
下面是我试图执行的代码

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();
}
}


我希望我能在这里得到一些建议和帮助。

谷歌最近开始禁止在其账户上使用简单和类似的方法


如果您想使用这种身份验证机制,帐户将需要启用它们-

Kev,谢谢帮助。启用身份验证机制后,我可以连接到Gmail并成功聊天。不客气。如果解决了这个问题,你能考虑接受答案吗?所以其他人可以找到答案吗?