0

I am trying to get the user info from FaceBook using FaceBook sdk in android.

I was able o login successfully. I am trying to get the user info from answer provided in the following link and I am getting the following error.

Please provide how to go further from here. enter image description here

I did not any error for the first time but I am getting the above error from the second time onwards.

Community
  • 1
  • 1
Baradwaj Aryasomayajula
  • 1,184
  • 1
  • 16
  • 42
  • your hash key is not matched with which you stored in facebook developer page. – Sagar Maiyad Nov 20 '14 at 04:38
  • Hey I got the answer ofcourse with help of the stackoverflow itself. I have taken the SHA1 ey from Eclipse->Windows->Preferences->Android->Build. I have converted the SHA1 key into Key Hash from the following site. http://tomeko.net/online_tools/hex_to_base64.php?lang=en . There is a slight mismatch in the key that got generated and the key which I got from convering SHA1. So I tried replacing it in the facebook developer and the app is working fine... – Baradwaj Aryasomayajula Nov 21 '14 at 19:54

1 Answers1

0

The error shows that you have forgot to include your hashkey in facebook developer page of your app. Try this code in onCreate of your Activity to get your Hashkey

try {
    PackageInfo info = getPackageManager().getPackageInfo(
            "com.example.packagename", 
            PackageManager.GET_SIGNATURES);
    for (Signature signature : info.signatures) {
        MessageDigest md = MessageDigest.getInstance("SHA");
        md.update(signature.toByteArray());
        Log.d("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
        }
} catch (NameNotFoundException e) {

} catch (NoSuchAlgorithmException e) {

}

the KehHash is generated in the logcat and you should copy and paste that in facebook developer page of your app.Also don't forget to use correct app_id in your project. Refer this link for more info.

Community
  • 1
  • 1
Mukesh Rana
  • 4,051
  • 3
  • 27
  • 39