com.facebook.FacebookAuthorizationException: Unkno

2020-06-28 01:05发布

问题:

I am a lot of time try to connect my android app with facebook but get excaption with the hash key. I read question here about this but didn succes to solve my problem

I run this code to get hash key

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

} catch (NoSuchAlgorithmException e) {

}

And it show me 12-12 14:19:29.615: D/com.example.fishe(5834): 5C440zhVwrb0ZQTs325My+VLZBo=

Now when I run the app and try to log in I get exception : (now the hash is with '-' instead of '+')

12-12 14:16:30.105: E/(5834): com.facebook.FacebookAuthorizationException: UnknownError: Key hash 5C440zhVwrb0ZQTs325My-VLZBo does not match any stored key hashes.

I try to insert to app - >edit setting ->native android app in https://developers.facebook.com first time the hash key with '+' and secondt time with '-' . Both times with the '=' at the end. I got the ecxception in both cases... What to do?

回答1:

so this is late but I absolutely need to post this because I had this problem for HOURS and when I solved it, I felt really angry and dumb. So I hope this helps some people.

When you paste your hash key into the facebook sample app (and I suspect any facebook app) on the website, a small drop down will show up. Click it so that your entered text is converted into a little box. THEN hit save. It is NOT just enough to paste it in and leave it as a string when you click on save.