7

I'm developing a hybrid app with Meteor and Cordova. I'm trying to configure Facebook Connect and got it working on iOS but I'm stuck on android. I cannot seem to find the correct key hash. I always get the message:

Invalid key hash. The key hash ... does not match any stored key hashes.

I already tried to find the correct key hash via the following command:

keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64

and the standard password "android". I added the resulting key to Facebook but it didn't help. I also tried the tool in the following post. It gave me another key which also did not work. Any ideas?

Community
  • 1
  • 1
Ravest
  • 73
  • 1
  • 3

3 Answers3

8

Meteor uses its own debug keystore when creating an android app via meteor run android-device. The keystore can be found at ~/.meteor/android_bundle/.android/debug.keystore.

Use the following code and the keystore password android for creating your keyhash:

keytool -exportcert -alias androiddebugkey -keystore \
~/.meteor/android_bundle/.android/debug.keystore | openssl sha1 -binary | openssl base64
Sebastian Rehm
  • 340
  • 2
  • 9
1

I went through the same problem and simply had to put the key which was on the error message on FB settings. It worked.

Chong Lip Phang
  • 8,755
  • 5
  • 65
  • 100
Pierrick Martellière
  • 1,554
  • 3
  • 21
  • 42
-1

Facebook keyhash works with your application's package name and keystore.

Get your apk signed with a production keystore and use below code to get the facbook keyhash

try {
PackageInfo info = getPackageManager().getPackageInfo("your package", PackageManager.GET_SIGNATURES);
for (Signature signature : info.signatures) {
    MessageDigest md = MessageDigest.getInstance("SHA");
    md.update(signature.toByteArray());
    Log.e("MY KEY HASH:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
}
} catch (NameNotFoundException e) {

} catch (NoSuchAlgorithmException e) {

}

The facebook Keyhash wil start with '=' equals to sign. For testing purpose you can have both keyhash from debug keystore as well as production keystore.

More information is available here.

Jitender Dev
  • 6,907
  • 2
  • 24
  • 35
  • I'm creating a cordova app like I said, so I wouldn't really know where to put your proposed Java code. There has to be a solution without using custom code? – Ravest Mar 09 '15 at 22:55
  • The post clearly states that it's a Cordova question, downvoted for not explaining how to put this in a Cordova project, although the code snippet actually worked. – Luís Brito Jun 21 '17 at 01:34