Ad

Firebase Facebook Login Hash Keys Issue

- 1 answer

I am using Facebook Login method for FireBase on my Android App. The error is the following: "Key hash B5dWUEYfZJL/...........jyA= does not match any stored key hashes". The error occurs when I have already installed the app, delete it and do a reinstall. The similar problem is described in the following link..

Facebook key hash does not match any stored key hashes

The suggested solution is to go to your Facebook Profile, delete the app from the permissions list in "Settings".like this..

enter image description here

The solution provided works and solves the problem, but you cannot go and ask a user of the app to go to his/her settings and delete app permissions when this happens.. Is there a way to avoid this problem in programming?

Ad

Answer

What I used to do when this happened was to add the key shown in the error message in the facebook console, but then I found that anoying and I discovered that I was using debug keys, which usually change.

Now I apply this method: Right before I generate the apk I run the release version of my app in the emulator, but I activate this method in my splash screen:

public void discoveryKeyHarsh() {
        try {
            PackageInfo info = getPackageManager().getPackageInfo(
                    "com.hmr.android.taskr",
                    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 (PackageManager.NameNotFoundException e) {

        } catch (NoSuchAlgorithmException e) {

        }
    }

It will show a keyhash that I then add to my facebook console. And I never had the "key does not match any stored key hashes" again.

Ad
source: stackoverflow.com
Ad