Posts Tagged ‘key hash’
Create Facebook Hash Key for Android apps
Currently doing a small Facebook client for Android. There are several steps we need to do to get the integration working properly. Here I just give a brief of how to create Hash key to update in Facebook. I did a lot of research to get things working, so thought of writing a post that give the details in one place.
Steps to create Hash Key.
-
Download openssl from Openssl for Windows . I downloaded the Win32 version
-
Unzip and copy all the files in the bin folder including openssl.exe
-
Goto to the folder where you installed JDK for me it’s C:\Program Files\Java\jdk1.6.0_21\bin
-
Paste all the files you copied from Openssl’s bin folder to the Jdk folder.
Now it’s time to run the command to generate the HashKey. You can find more details of Facebook sdk here
keytool -exportcert -alias androiddebugkey -keystore [Key_store_path] | openssl sha1 -binary | openssl enc -a -e
Above command needs the path to your debug keystore. You can find the Keystore path using Eclipse. Goto Window->Preference->Android->Build will open up a window as shown below.
You can find the Default debug keystore. Copy the path and update in our command, now the command will be like
keytool -exportcert -alias androiddebugkey -keystore C:\Users\sarouje\.android\debug.keystore | openssl sha1 -binary | openssl enc -a -e
Fire a command prompt and paste the command and run it. Tool will generate a key for you.
Edit: I was not successful in generating right Key Hash using command prompt or cygWin. My search leads to this post explains how to generate right key for the app. Author also provided the Eclipse project contains the source.
Update Hash Key in Facebook
Goto to your Facebook app page and click Edit settings of your app. Click on the Mobile Native section, page will expand and show the section as shown below
Update the HashKey in the Android Key Hash Textbox and click save changes. We are done, go ahead and run your app and it will work fine. No more Invalid key exception
Edit (Jun-24-2014): Nezzar Waleed notified me about one easy solution he found out in stackoverflow, please check it out as well.