1

i m working on Facebook chat and the code is working fine till connecting to chat.facebook.

bt1.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            TAG = ed1.getText().toString();
            try {
                testlogin();

            } catch (Exception e) {

                e.printStackTrace();
            }

        }
    });

and the method is:

private void testLogin() {
    ConnectionConfiguration config = new ConnectionConfiguration(
            "chat.facebook.com", 5222);
    config.setSASLAuthenticationEnabled(true);
    config.setSecurityMode(ConnectionConfiguration.SecurityMode.enabled);
    xmpp = new XMPPConnection(config);

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        config.setTruststoreType("AndroidCAStore");
        config.setTruststorePassword(null);
        config.setTruststorePath(null);
    } 
    else {
        config.setTruststoreType("BKS");
        String path = System.getProperty("javax.net.ssl.trustStore");
        if (path == null)
            path = System.getProperty("java.home") + File.separator + "etc"
                + File.separator + "security" + File.separator
                + "cacerts.bks";
        config.setTruststorePath(path);
    }
    SASLAuthentication.registerSASLMechanism("X-facebook-PLATFORM",
            SASLXFacebookPlatformMechanism.class);
    SASLAuthentication.supportSASLMechanism("X-facebook-PLATFORM", 0);
    Log.i("XMPPClient", "Access token to " + mFacebook.getAccessToken());
    Log.i("XMPPClient", "Access token to " + mFacebook.getAppId());
    Log.i("XMPPClient", "Access token to " + mFacebook.getAccessToken());
    try {
        xmpp.connect();
        Log.i("XMPPClient", "Connected to " + xmpp.getHost());

    } catch (XMPPException e1) {
        Log.i("XMPPClient", "Unable to " + xmpp.getHost());

        e1.printStackTrace();
    }
    try {
        xmpp.login(mFacebook.getAppId(), mFacebook.getAccessToken()); // error point
        Log.i("XMPPClient", " its logined ");

    } catch (Exception e) {
        e.printStackTrace();
    }
}

later i have provided the APPid along with the valid access token to xmpp.login(,), but is giving an exception:

  07-15 01:47:26.929: W/System.err(12719): SASL authentication failed using mechanism    DIGEST-MD5: 
  07-15 01:47:26.929: W/System.err(12719):  at org.jivesoftware.smack.SASLAuthentication.authenticate(SASLAuthentication.java:342)
  07-15 01:47:26.929: W/System.err(12719):  at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:230)
  07-15 01:47:26.939: W/System.err(12719):  at org.jivesoftware.smack.Connection.login(Connection.java:353)
  07-15 01:47:26.939: W/System.err(12719):  at com.example.checking.MainActivity.testLogin(MainActivity.java:320)
  07-15 01:47:26.939: W/System.err(12719):  at com.example.checking.MainActivity.access$0(MainActivity.java:279)
  07-15 01:47:26.939: W/System.err(12719):  at com.example.checking.MainActivity$userDetailFB.onPostExecute(MainActivity.java:238)
  07-15 01:53:24.419: W/System.err(12885):  at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:239)
Akhilesh Sk
  • 451
  • 4
  • 18

0 Answers0