تفويض SASL فشل أثناء الاتصال بخادم XMPP
-
03-10-2019 - |
سؤال
أحاول الاتصال بـ Gmail باستخدام Smack API من خلال خادم XMPP. لكن الحصول على
خطأ: فشلت مصادقة SASL باستخدام آلية واضحة
يمكنك التحقق من لمحة عن الكود. حصلت عليه من الشبكة فقط
ConnectionConfiguration connConfig = new ConnectionConfiguration("talk.google.com", 5222, "gmail.com");
connection = new XMPPConnection(connConfig);
connection.connect();
SASLAuthentication.supportSASLMechanism("PLAIN", 0);
راجعت في نافذة تصحيح Smack. تقول في XML:
<غير صالح-Authzid />
لدي بالفعل حساب على Gmail و My Gtalk يعمل أيضًا.
المحلول
تحتاج إلى تعيين المصادقة قبل توصيل بمعنى
SASLAuthentication.supportSASLMechanism("PLAIN", 0);
يجب أن تظهر من قبل connection.connect()
.
انظر بلدي مقالات.
نصائح أخرى
ConnectionConfiguration cc = new ConnectionConfiguration(
"vietnam.agilemobile.com", 5222, vietnam.agilemobile.com");
XMPPConnection connection = new XMPPConnection(cc);
try {
SASLAuthentication.supportSASLMechanism("PLAIN", 0);
connection.connect();
Log.e("LOGIN", "" + 111);
// You have to put this code before you login
Log.e("LOGIN", "" + 222);
// You have to specify your gmail addres WITH @gmail.com at the end
connection.login("nemodo", "123456", "resource");
Log.e("LOGIN", "" + 333);
// See if you are authenticated
System.out.println(connection.isAuthenticated());
} catch (XMPPException e1) {
e1.printStackTrace();
}
كما أنني أحصل على هذا الخطأ ، لكنني لا أستطيع العمل.
لا تنتمي إلى StackOverflow