Bha*_*anu 3 xmpp google-talk smack
我正在尝试使用SMACK API连接到gmail,但得到以下错误,我在过去的2天内陷入困境.
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)
Run Code Online (Sandbox Code Playgroud)
我正在使用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.
Run Code Online (Sandbox Code Playgroud)
下面是我试图执行的代码.
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();
}
Run Code Online (Sandbox Code Playgroud)
}
我希望我能在这里得到一些建议和帮助.
Kev*_*Kev 10
谷歌最近已改用其帐户不允许使用PLAIN和类似方法 - https://support.google.com/accounts/answer/6010255.
如果您想使用此类身份验证机制,则该帐户需要启用它们 - https://www.google.com/settings/security/lesssecureapps
| 归档时间: |
|
| 查看次数: |
2559 次 |
| 最近记录: |