6

I have recently got Facebook to work when debugging my application by following the insructions on facebooks developer page on how to export and get the hash key we need to put in the developer portal.

So now this is done, i tried using facebook log in with a exported and signed version of my application. Unfortunately i was not able to get it to work. It would never return a log in session after logging in through the facebook app or web page.

I believe this is due to the keys being difference between the released and signed apk and the apk i use to debug.

Anyone know how to fix this problem?

3 Answers3

9

You are correct on the key hash's being different from the debug.keystore and the release signing key. To remedy that, follow the steps on this website here: http://www.helloandroid.com/tutorials/using-facebook-sdk-android-development-part-1

It has a nice tutorial that will fix the issue in almost no time.

The gist of it is:

  1. Download OpenSSl for Windows and extract the .zip to a simple location like: c:\openssl with all the contents of the zip extracted in this folder's root.
  2. Copy your signing key file to your JRE installation's bin folder. For example, in my case: C:\Program Files\Java\jre7\bin
  3. While in the bin folder where you copied the signing key, Press SHIFT+ Right Click -> Open command window here.
  4. Run this command: keytool -exportcert -alias YOUR_ALIAS -keystore YOUR_SIGNING_KEY > c:\openssl\bin\debug.txt
  5. Enter your password for the signing key
  6. Now, navigate to the c:\openssl\bin folder and type in the following commands:

openssl sha1 -binary debug.txt > debug_sha.txt

And then,

openssl base64 -in debug_sha.txt > debug_base64.txt

Done! The debug_base64.txt contains your Key Hash. Copy this in your app console and you are all set.

This sounds lengthy, but you really will be done in literally 4 - 5 minutes. ;-)

Siddharth Lele
  • 27,623
  • 15
  • 98
  • 151
  • the keystore file is the file ending in extension .jks right? I am trying to use it in the command line and i keep getting access denied for some reason – Coder_Moler10345 Feb 21 '13 at 13:34
  • I manage to get the debug.txt to work but now i get debug.txt: No such file or directory openssl: No such file or directory base64: No such file or directory in: No such file or directory debug_sha.txt: No such file or directory – Coder_Moler10345 Feb 21 '13 at 13:47
  • No when i run the commend openssl sha1 -binary debug.txt > debug_sha.txt openssl base64 -in debug_sha.txt > debug_base64.txt i get: No such file or directory openssl: No such file or directory base64: No such file or directory in: No such file or directory debug_sha.txt: No such file or directory – – Coder_Moler10345 Feb 21 '13 at 14:56
  • @Coder_Moler10345: Oh oh oh. I feel extremely stupid now. Please check the correction. They are actually two different commands. But they were joined together when I used the _quote block_ in my post. I am so sorry fella. :-( – Siddharth Lele Feb 21 '13 at 15:00
  • I am in the openssl directory too. – Coder_Moler10345 Feb 21 '13 at 15:10
  • @Coder_Moler10345: Check the edit. You may have to delete the openssl folder and recreate it. Perhaps, even redo all the steps. – Siddharth Lele Feb 21 '13 at 15:11
  • @Coder_Moler10345: Glad to have helped. :-) – Siddharth Lele Feb 21 '13 at 16:00
  • @eng.ahmed: Glad to have been of help. :-) – Siddharth Lele Dec 21 '13 at 03:36
  • @eng.ahmed: Nope. That's not me. Just another dude sharing names. ;-) – Siddharth Lele Dec 21 '13 at 05:08
  • i tried this way but don't know why always my debug_base64.txt is blank. – Ajay May 22 '14 at 05:48
  • @Ajay: Well, this procedure has worked for me as long as I can remember. It is also know to work for others too. Perhaps, you could review every step properly. You could have accidentally skipped one or two. – Siddharth Lele May 22 '14 at 05:50
  • what is YOUR_SIGNING_KEY in following command.................... keytool -exportcert -alias YOUR_ALIAS -keystore YOUR_SIGNING_KEY > – Coas Mckey Sep 16 '15 at 15:46
  • Following all step still the debug_base64.txt is still blank.Actually when i write this command openssl sha1 -binary debug.txt > debug_sha.txt .It gives debug.txt: No error as an output.Is this is normal.Need some help. – blackjack Dec 15 '15 at 05:33
0

In order to generate the key Please follow the steps provided above. the main problem you can face will be alias as it'll throw exception: keytool error: unable to find alias (likely). if you have signed key to release the app fetch alias of that key using:

keytool -list -keystore

Now use this alias in keytool -exportcert -alias -keystore c:\openssl\bin\debug.txt

Now you can follow the steps mentioned in the previous comment.

Pranav
  • 808
  • 10
  • 10
0

Copy Paste the SHA1 key to the link.

Internally its converting Hex to Base64.

We can convert from this Website directly.

worked for me.enter image description here

vinay shetty
  • 895
  • 1
  • 9
  • 15