使用 Smack 集成 Facebook 聊天时 SASL 身份验证失败
我正在尝试使用 smack API 集成 facebook 聊天。但是我收到一条错误消息,告诉我使用摘要 md5 身份验证失败...
这是身份验证代码:
SASLAuthentication.registerSASLMechanism("DIGEST-MD5", SASLDigestMD5Mechanism.class);
SASLAuthentication.supportSASLMechanism("DIGEST-MD5", 0);
ConnectionConfiguration config = new ConnectionConfiguration("chat.facebook.com",5222);
connection = new XMPPConnection(config);
config.setSASLAuthenticationEnabled(true);
connection.connect();
connection.login(userName, password);
下面是我运行它时收到的错误:
Exception in thread "main" SASL authentication failed using mechanism DIGEST-MD5:
at org.jivesoftware.smack.SASLAuthentication.authenticate(SASLAuthentication.java:325)
at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:395)
at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:349)
at JabberSmackAPIFacebook.login(JabberSmackAPIFacebook.java:31)
at JabberSmackAPIFacebook.main(JabberSmackAPIFacebook.java:77)
我可以成功连接到 gtalk,但是我没有成功 vit fb... 苏莫能告诉我问题是什么吗
I am trying to integrate facebook chat using smack API.But i get an error telling authentication failed using digest md5...
Here s the code for authentication:
SASLAuthentication.registerSASLMechanism("DIGEST-MD5", SASLDigestMD5Mechanism.class);
SASLAuthentication.supportSASLMechanism("DIGEST-MD5", 0);
ConnectionConfiguration config = new ConnectionConfiguration("chat.facebook.com",5222);
connection = new XMPPConnection(config);
config.setSASLAuthenticationEnabled(true);
connection.connect();
connection.login(userName, password);
below is the error i get wen i run it:
Exception in thread "main" SASL authentication failed using mechanism DIGEST-MD5:
at org.jivesoftware.smack.SASLAuthentication.authenticate(SASLAuthentication.java:325)
at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:395)
at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:349)
at JabberSmackAPIFacebook.login(JabberSmackAPIFacebook.java:31)
at JabberSmackAPIFacebook.main(JabberSmackAPIFacebook.java:77)
I can successfully connect to gtalk but am having no success vit fb...
can sumone tel me wat s the problem
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
对我来说,解决方案是在不使用 DNS SRV 且不使用 Google Talk 服务的情况下调用
login()
时不在用户名中包含主机部分。这也在 ignite 论坛中进行了描述。例如
变成
For me the solution was to not include the host part in the username when calling
login()
without DNS SRV and not agains the Google Talk services. This is also described in the ignite forums.E.g.
becomes
Ignite 上有一个巨大的线程处理这个问题。您可能想看看它,因为有几种针对 Java 和 Android 的解决方案似乎可行。
There is a huge thread at Ignite that deals with this issue. You may want to take a look at it as there are several solutions for Java and Android given that seem to work.
我已经使用 DIGEST-MD5 成功连接到 facebook,您发布的代码看起来不错。
但我们仍然需要检查您的 SASLDigestMD5Mechanism 类的内容
我已成功使用此处提供的类
http ://community.igniterealtime.org/message/200878#200878
另外,您还必须注意,在 DIGEST-MD5 机制中,您必须使用您的 facebook 用户名登录,而不是使用电子邮件登录地址。默认情况下,Facebook 帐户没有用户名,您必须先创建一个用户名,您可以在此处查看:
http://www.facebook.com/用户名/
I have succesfully connected using DIGEST-MD5 to facebook, the code you have posted looks good.
But still we need to check the contents of your SASLDigestMD5Mechanism class
I have used the class provided in here with success
http://community.igniterealtime.org/message/200878#200878
Also you have to notice that in the DIGEST-MD5 mechanism you have to login with your facebook username and not with the email address. By default the facebook accounts don't have a username, you have to create one fisrt, you can check that in here:
http://www.facebook.com/username/
MainActivity.java
SASLXFacebookPlatformMechanism.java
MainActivity.java
SASLXFacebookPlatformMechanism.java