0

I'm integrated facebook login in my app and the key hash created for production using release .jks play store signin file and generated keyhash added in fb console and no other key hash added. now when i try to login using fb login it gives error:

Invalid key hash. The key hash xxxxfgxxxdfdsxxx= does not match any stored key hashes. Configure your app key hashes at https://developers.facebook.com/apps/xxxxx7xx4xxxx/

and above (xxxxfgxxxdfdsxxx=) given key hash is not even in my fb developer console.

1 Answers1

0

I don't know why but looking Facebook needs 2 key hashes,

1) we create using .jks file release key hash,

keytool -exportcert -alias <RELEASE_KEY_ALIAS> -keystore <RELEASE_KEY_PATH> | openssl sha1 -binary | openssl base64

and

2) it also shows us in device that (xxxxxxxxxx=) key doesn't match in your key hashes.

It uses this method in your activity.

public void getHashkey(){
    try {
        PackageInfo info = getPackageManager().getPackageInfo(getApplicationContext().getPackageName(), PackageManager.GET_SIGNATURES);
        for (Signature signature : info.signatures) {
            MessageDigest md = MessageDigest.getInstance("SHA");
            md.update(signature.toByteArray());

            Log.i("Base64", Base64.encodeToString(md.digest(),Base64.NO_WRAP));
        }
    } catch (PackageManager.NameNotFoundException e) {
        Log.d("Name not found", e.getMessage(), e);

    } catch (NoSuchAlgorithmException e) {
        Log.d("Error", e.getMessage(), e);
    }
}

So when we enter both key hashes. It works perfectly.

Chintak Patel
  • 748
  • 6
  • 24