Android Facebook Login

Hi:

Im using Corona Facebook API on Android, and Im having the following issue. When I open the app for first time facebook asked me for the permissions I require, I accept and everything is ok. The second time I open the app and try to login to Facebook again I get the following error

Error

Invalid android_key parameter. The key ??? does not match any allowed key. Configure your app key hashes athttp://developers.facebook.com/apps/XXXXXXXXXXXXXX

 

The key they mention is not the key hash I set before. I get the key hash from my release keystore.

I dont understand why the second time is not working. Any help about this would be great.

 

Thanks in advance

Figuring out keyhash’s is one of the most painful things a Corona SDK developer can go through if you don’t understand what hasheys are and don’t understand what the command you are typing in really do.

There are two main points of failure (well three, but one of them has two issues). 

One:  The command line you are typing in is assuming you are going to change values to match your reality.  You can’t blindly cut and paste the command and have it work.  Where you have your keystore’s stored is very likely not where that command is looking for them.  It can’t find your real keystore and outputs an error, but because the string is 3 commanded piped into each other, the final command generates a keyhash based on the string “File not found”, not your valid keystore.  If you don’t type the password in correctly, it will still generate a keyhash, but based on the string “invalid password” not your valid keystore.

The sub-issue with this is the default one most people use are  using the Android debug keystore.  However, Corona SDK’s Android debug keystore is a different file than the default Android debug keystore and therefore will not match.  I don’t recommend using the debug keystore for Facebook testing because you will forget to change it to your release keystore when you go live and your facebook will be broken.

Two:  There are a couple of different implementations of OpenSSL for windows.  The one you have likely isn’t generating the keyhash that Facebook is looking for.

Please read this tutorial carefully and you should get a valid keyhash.

http://coronalabs.com/blog/2013/07/30/understanding-facebook-authentication/

Hi Rob thanks for the fast answer. Actually I think my key hash is working because the first time I open the app it work just fine Facebook ask me for the permission my app is requesting and everything is good, but the second time I open the app is when that error is shown. Also I already have the issues you mentioned with the keystore key hash creation.

What I really dont understand is why the first time it work just fine, and the second time is not working.

Hi Rob I found a post here http://forums.coronalabs.com/topic/44889-facebook-posting-on-android/ from you with sample code, and is working now in my Nexus 7, also I fixed the previous issue in the following way, when Facebook says, invalid android_key… no key match xxxxxxxxxxxxxxxxxxxx I add that key to my key hashes in Facebook developer page and is working.

Figuring out keyhash’s is one of the most painful things a Corona SDK developer can go through if you don’t understand what hasheys are and don’t understand what the command you are typing in really do.

There are two main points of failure (well three, but one of them has two issues). 

One:  The command line you are typing in is assuming you are going to change values to match your reality.  You can’t blindly cut and paste the command and have it work.  Where you have your keystore’s stored is very likely not where that command is looking for them.  It can’t find your real keystore and outputs an error, but because the string is 3 commanded piped into each other, the final command generates a keyhash based on the string “File not found”, not your valid keystore.  If you don’t type the password in correctly, it will still generate a keyhash, but based on the string “invalid password” not your valid keystore.

The sub-issue with this is the default one most people use are  using the Android debug keystore.  However, Corona SDK’s Android debug keystore is a different file than the default Android debug keystore and therefore will not match.  I don’t recommend using the debug keystore for Facebook testing because you will forget to change it to your release keystore when you go live and your facebook will be broken.

Two:  There are a couple of different implementations of OpenSSL for windows.  The one you have likely isn’t generating the keyhash that Facebook is looking for.

Please read this tutorial carefully and you should get a valid keyhash.

http://coronalabs.com/blog/2013/07/30/understanding-facebook-authentication/

Hi Rob thanks for the fast answer. Actually I think my key hash is working because the first time I open the app it work just fine Facebook ask me for the permission my app is requesting and everything is good, but the second time I open the app is when that error is shown. Also I already have the issues you mentioned with the keystore key hash creation.

What I really dont understand is why the first time it work just fine, and the second time is not working.

Hi Rob I found a post here http://forums.coronalabs.com/topic/44889-facebook-posting-on-android/ from you with sample code, and is working now in my Nexus 7, also I fixed the previous issue in the following way, when Facebook says, invalid android_key… no key match xxxxxxxxxxxxxxxxxxxx I add that key to my key hashes in Facebook developer page and is working.