30

When I try to implement Facebook Connect in my Android application, I get the following error.

11-02 16:41:31.660: D/Facebook-authorize(13194): Login failed: invalid_key:Android key mismatch. Your key "8Ioc4p/jMXoU9Lezug4nzmZfFUg" does not match the allowed keys specified in your application settings. Check your application settings at http://www.facebook.com/developers

I reset the key in the Facebook App and still it shows the same error. How can I fix it?

2
  • 1
    I noticed in my AndroidManifest.xml, I had: android:launchMode="singleInstance" I never got the key invalid error. But when I removed that line, I started getting the key invalid error. I don't know how or is it related to this error.
    – Lisa
    May 3, 2012 at 13:41
  • @Harsha M V. my hash key is YLMxxxxxxxxxxxxxxxR8= which i get in the command prompt. but the error is same as yours saying YLMxxxxxxxxxxxxxR8 does not match the allowed keys. So should i remove = from the hash key in the configurations?? Because the accepted answer below shows an =. How did you solve it? Thank You Oct 24, 2012 at 13:48

10 Answers 10

65

Your key is: "8Ioc4p/jMXoU9Lezug4nzmZfFUg"

Now copy this key and open this URL, and paste this key in the native Android app, marked with a green border.

Enter image description here

5
  • hey buddy if u open so many threads they will down vote u :P use the Edit Button to edit ur answers.. on the same one. and thanks a lot :) i will ping u directly if i need some help hope its fine
    – Harsha M V
    Nov 3, 2011 at 8:33
  • 6
    so that = is extra or no need to add there ? May 14, 2013 at 12:26
  • I'm having this issue now too with facebook connect, and I've checked so many times that the keys do match and I'm using the right app_id and everything, I am but I still can't get it to work. Jun 23, 2013 at 0:19
  • That is what is called "The address is on the wall" :) Nov 26, 2015 at 10:27
  • @user647826 Can you please tell me why Facebook showing this error ? Facebook showing different key has and I got the different released key hash from command prompt. How can i achieve this hash key before make the app live ? What would be the proper solution for this for future apps Jul 6, 2017 at 12:09
11

I dont know if your problem is resolved right now but I was having the same problem as you and now I find the complete solution.

You have two enviroments for the development: debug and a signed application, when you use this commands to get your key

keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64 you are getting the key for the debug.keystore,

But when you sign the app you get a new key because your app is using a new keystore.You can get your "sign app key" using this program. http://www.easyfacebookandroidsdk.com/download/keyhash.zip but you have to sign with the same keystore that you are using in your app.

3
  • +1 thx - for some reason the command line solution of keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64 didnt work for me as it was giving a differnt hash (and my project is using that location to find the debug keystore) but the easy facebook SDK mentioned in this comment worked! Saying that the generated hash was a few chars differnt from the one reported in the app on error ( + to -, _ to /) - which is weird.
    – Dori
    Aug 30, 2013 at 8:27
  • I am having the same problem where my app's signature does not match what the FB directions for keytool outputs. Anyone have any idea why this is?
    – swooby
    Feb 17, 2015 at 19:28
  • 1
    What do I do with that zip file? Mar 19, 2015 at 0:23
5

Your key is

8Ioc4p/jMXoU9Lezug4nzmZfFUg

This key is encrypted by your device so you have we have to let this key be known to Facebook user (in your application which you create in Facebook).

Now you have to copy this key in the native app and then save it. After some minutes, you can get all access..

1
  • how can i set this key to my application. it looks like this is the default debug key for my installation.
    – Harsha M V
    Nov 2, 2011 at 19:53
4

The error for me was caused by the mismatch between my debugging key when I was testing my app and the release key when I was signing a release version.

11-02 16:41:31.660: D/Facebook-authorize(13194): Login failed: invalid_key:Android key mismatch. Your key "8Ioc4p/jMXoU9Lezug4nzmZfFUg" does not match the allowed keys specified in your application settings. Check your application settings at http://www.facebook.com/developers

If you copy and paste 8Ioc4p/jMXoU9Lezug4nzmZfFUg to the Android Key Hash field in the Facebook application settings it should work. If you get this error again (showing a different key value) when you test your signed release version, copy that additional key into the Hash Field after the original entry, so you have two values in there.

I was surprised that more than one entry was allowed in the Key Hash Field, but it appears it is ok and it's solved the problem for me for both testing and release versions.

1
  • I voted this up only because the solution worked for me -- pasting the error message's key hash into my FB app settings "Key Hashes" field.
    – Pup
    Jul 24, 2015 at 19:08
2

The debug native Android application key is generated automatically using debug.keystore file located at ~/.android/debug.keystore. When you are developing your application on multiple machines, you should have the same debug.keystore file...

Once this is done, you can paste the debug native Android application key to the Facebook settings page of your application.

2

You actually do not past this key directly, but a Base64 value of this key.

Refer to https://developers.facebook.com/docs/mobile/android/build/#sig which explains you how to generate this.

1

Please check your application page in Facebook and confirm that both keys are same. I think you won't register your app on Facebook

1

You can use Facebook application in your application so you use this. In that source code for Facebook integration is there.

1

If the key is invalid, then you have to create the new Facebook application on the Facebook developers site. It provides you with a new key. Use that key in your Facebook demo.

1
0

I have this problem, I solved it by deleting "C:\Users\user_name.android\debug.keystore" and generating a new one with eclipse. Then I change the old hash key from Facebook and it works!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.