Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SessionState is CLOSED_LOGIN_FAILED in FB native login

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 .

like image 950
VIGNESH Avatar asked Dec 16 '22 13:12

VIGNESH


2 Answers

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) {

}
like image 194
Shahid Pasha Avatar answered Dec 26 '22 18:12

Shahid Pasha


I just ran into this issue and tried all the solutions mentioned above, none of which resolved the issue. In my case, I kept getting this error on my test device phone (htc my touch). I noticed that when I tried logging into facebook with my browser on the phone, it kept giving me certificate errors! So I finally figured out that the date and time on my phone was not correct. After fixing that, the CLOSED_LOGIN_FAILED error went away. Hope that helps someone in the future!

like image 28
rainman333 Avatar answered Dec 26 '22 19:12

rainman333