powered by Jive Software

Problems with connecting to Facebook XMMP MD5-DIGEST

Would be very grateful for a look at your code here. I’m really struggling with this. Keep getting 503 issues (I have all necessary permissions). tried using the code here: http://stackoverflow.com/questions/5317329/xmpp-with-java-asmack-library-support ing-x-facebook-platform

But the client factory in org.apache.harmony.javax.security.sasl.Sasl is the last place I can trace to problem to.

Tried using the app secret and the session secret and the name. Both return 503

Hi,

after using the code that you have posted up; i’ve got an error message

SASL authentication DIGEST-MD5 failed: not-authorized:

at org.jivesoftware.smack.SASLAuthentication.authenticate(SASLAuthentication.java: 337)

at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:203)

at org.jivesoftware.smack.Connection.login(Connection.java:348)

at Facebook.login(Facebook.java:46)

at Facebook.main(Facebook.java:16)

any help !!!

I just ran that code again & found everything fine.Did you added the class successfully?If you have problem with the class try to include this Jar in your classpath instead: http://fbserver.99k.org/SASL.jar

Hi

now i’ve got this error message :

connected to facebook

Exception in thread “Smack Packet Reader (0)” java.lang.NoSuchMethodError: org.jivesoftware.smack.SASLAuthentication.send(Ljava/lang/String;)V

at MySASLDigestMD5Mechanism.challengeReceived(MySASLDigestMD5Mechanism.java:80)

at org.jivesoftware.smack.SASLAuthentication.challengeReceived(SASLAuthentication. java:514)

at org.jivesoftware.smack.PacketReader.parsePackets(PacketReader.java:296)

at org.jivesoftware.smack.PacketReader.access$000(PacketReader.java:43)

at org.jivesoftware.smack.PacketReader$1.run(PacketReader.java:70)

No response from the server.:

at org.jivesoftware.smack.NonSASLAuthentication.authenticate(NonSASLAuthentication .java:73)

at org.jivesoftware.smack.SASLAuthentication.authenticate(SASLAuthentication.java: 352)

at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:203)

at org.jivesoftware.smack.Connection.login(Connection.java:348)

at Facebook.login(Facebook.java:45)

at Facebook.main(Facebook.java:15)

**here is my code **

import org.jivesoftware.smack.ConnectionConfiguration;

import org.jivesoftware.smack.SASLAuthentication;

import org.jivesoftware.smack.XMPPConnection;

import org.jivesoftware.smack.XMPPException;

public class Facebook {

/**

  • @param args

*/

public static void main(String[] args) {

// TODO Auto-generated method stub

try {

        login("user@yahoo.com", "pass");

} catch (XMPPException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

public static void login(String userName, String password) throws XMPPException

{

SASLAuthentication.registerSASLMechanism(“DIGEST-MD5”,MySASLDigestMD5Mechanism. class);

//((SASLAuthentication) ss).registerSASLMechanism(“DIGEST-MD5”,MySASLDigestMD5Mechanism.class);

ConnectionConfiguration config = new ConnectionConfiguration(“chat.facebook.com”,5222);

config.setSASLAuthenticationEnabled(true);

config.setRosterLoadedAtLogin (true);

XMPPConnection connection = new XMPPConnection(config);

connection.connect();

System.out.print(“connected to facebook\n”);

connection.login(userName, password);

System.out.print(“logged to facebook\n”);

}

}

nb: in your Zip file a “chatFrame” class is missing , that’s why i 've rewrite it without this class

thnx

u r trying to enter facebook so why there is user@yahoo.com???I forgot

to tell one thing you can not enter facebook from smack using your

mail id.You must have an username in facebook.If you dont have create

one from your facebook account section.And enter the username in ur

app;this time it must run!

And one thing sometimes smack fails to connect in that case re-run ur app.

event

hi wvwn i am new to samck api

and trying to connect to facebook and followed your steps mentioned above but got the following error

connected to facebook

Exception in thread “Smack Packet Reader (0)” java.lang.NoSuchMethodError: org.j

ivesoftware.smack.SASLAuthentication.send(Ljava/lang/String;)V

at MySASLDigestMD5Mechanism.challengeReceived(MySASLDigestMD5Mechanism.j

ava:80)

at org.jivesoftware.smack.SASLAuthentication.challengeReceived(SASLAuthe

ntication.java:514)

at org.jivesoftware.smack.PacketReader.parsePackets(PacketReader.java:29

at org.jivesoftware.smack.PacketReader.access$000(PacketReader.java:43)

at org.jivesoftware.smack.PacketReader$1.run(PacketReader.java:70)

No response from the server.:

at org.jivesoftware.smack.NonSASLAuthentication.authenticate(NonSASLAuth

entication.java:73)

at org.jivesoftware.smack.SASLAuthentication.authenticate(SASLAuthentica

tion.java:352)

at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:203)

at org.jivesoftware.smack.Connection.login(Connection.java:348)

at Facebook.login(Facebook.java:93)

at Facebook.main(Facebook.java:33)

D:\try fb>

my code is

import org.jivesoftware.smack.ConnectionConfiguration;

import org.jivesoftware.smack.SASLAuthentication;

import org.jivesoftware.smack.XMPPConnection;

import org.jivesoftware.smack.XMPPException;

public class Facebook {

/**

  • @param args

*/

public static void main(String[] args) {

// TODO Auto-generated method stub

try {

login(“facebokusername”, “fbpasword”);

} catch (XMPPException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

public static void login(String userName, String password) throws XMPPException

{

SASLAuthentication.registerSASLMechanism(“DIGEST-MD5”,MySASLDigestMD5Mechanism. class);

//((SASLAuthentication) ss).registerSASLMechanism(“DIGEST-MD5”,MySASLDigestMD5Mechanism.class);

ConnectionConfiguration config = new ConnectionConfiguration(“chat.facebook.com”,5222);

config.setSASLAuthenticationEnabled(true);

config.setRosterLoadedAtLogin (true);

XMPPConnection connection = new XMPPConnection(config);

connection.connect();

System.out.print(“connected to facebook\n”);

connection.login(userName, password);

System.out.print(“logged to facebook\n”);

}

}

i have used the facebook username and the password for the same but could not log in to accoutn and ended up with the above error

evne i tried your zip files but have the same error for them, after removing the chatframe code fragment

please help…

Hi alexryd and everyone,

Since this post was made, it seems Facebook have changed their API somewhat; this thread, and your post in particular, have been very helpful for me in getting things to work, so I’m contributing back an updated solution which works for me.

The attached source is a new version of the SASL Mechanism for Facebook Platform; it is simpler than the earlier version, as the sig is no longer required.

The usage is similar to the previous version, but again simpler: You don’t need the session key. The one thing that is slightly more complex is that, instead of the application secret, you now use an access token that you need to get from Facebook (see http://developers.facebook.com/docs/authentication/). Facebook (in https://developers.facebook.com/docs/chat/) recommend you use the client flow to get the token, and that’s what I did; the server flow is supposed to yield a similar token, so it should work just as well.

The new usage code looks like:

SASLAuthentication.registerSASLMechanism(SASLXFacebookPlatformMechanism.NAME, SASLXFacebookPlatformMechanism.class);
SASLAuthentication.supportSASLMechanism(SASLXFacebookPlatformMechanism.NAME, 0); ConnectionConfiguration config = new ConnectionConfiguration("chat.facebook.com", 5222); XMPPConnection connection = new XMPPConnection(config);
connection.connect();
connection.login(apiKey, accessToken, "Client Name"); // Client name optional

Hope this helps,

Shai.
SASLXFacebookPlatformMechanism.java.zip (1576 Bytes)

1 Like

So to reply to the ORIGINAL discussion at hand, for those who are NOT trying to do X-Facebook, but just DIGEST-MD5, if you seemingly tried EVERYTHING you’ve found online without any luck like I did for hours while banging my head into the keyboard, I did finally get facebook chat working with asmack.

If you’re getting a failed not authorized for DIGEST-MD5 and are using the asmack library try the following: go to facebook.com/username, make sure you have a username chosen first, then LOGOUT and log back in using ONLY your username and password. If you’re like me, and hate facebook, but somehow found themselves coding a chat client, you might have had an old account when they used to be based on purely email addresses, so technically before doing the above steps, my userid was xxx@email.com@chat.facebook.com which is retarded on facebooks part.

I’m logged into facebook now from my client using only the asmack lib, no custom mysaslmechanism classes or anything.

Hope that helps some of your frustrated devs out there.

Hi Abdul,

I have tried importing the SASL.jar in my build path. However, I still have issues with

  1. MySASLDigestMD5Mechanism cannot be resolved to a type

  2. faceBook cannot be resolved to a type

  3. chatFrame cannot be resolved to a type

Hi @Solaiemes,

Did you get the resolution to issue you were facing with "getSASLAuthentication().send(stanza.toString()); "?

The error I am getting is,

The method send(Packet) in the type SASLAuthentication is not applicable for the arguments (String)

Thanks!