SessionState is CLOSED_LOGIN_FAILED in FB native login

android, facebook-login

Solution

Instead of generating the keyhash thorough command line use the following code to get the key hash. Some other things you need to take care of is 1)setting a proper package name in the facebook settings 2) enabling facebook login on facebook app settings dashboard

try {
    PackageInfo info = getPackageManager().getPackageInfo(
            "com.example.com.tvishi.fb", 
            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) {

}

Problem

i want to use Facebook Native login i am following http://developers.facebook.com/docs/tutorials/androidsdk/3.0/scrumptious/authenticate/ . i get the permissions alert box but when i select `ok` i get the SessionState as CLOSED_LOGIN_FAILED . i rechecked the App keyHash also . Is there any method to get the KeyHash from the code itself , i mean to print the keyhash with which it checks while comparing . i went through many other threads too but was not successful , i dont know where i am going wrong . what are all the possibilities , so that i may recieve this error . Any related answers are welcomed .

Original source

Related problems