Skip to content Skip to sidebar Skip to footer

How To Generate Key Hash For Facebook Sdk In Mac

I'm trying to obtain the key hash for integrating facebook into my Android app. But all over the net I can't find the way to do it on MAC OS X, only for Windows. If someone could

Solution 1:

I used following steps to generate a Key Hash for my app in facebook: (I am using Mac OSX 10.8)

  1. First open a terminal (open a command prompt in windows).
  2. Navigate in the terminal to the directory where your Android debug.keystore is stored.
  3. Mostly it will located under “/Users/user_name/.android/” (In Windows will be C:\Documents and Settings\.android).
  4. Once you are in the “.android” directory, run the following command.

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

  5. When it prompts you for a password, type android and hit Enter

  6. Copy the value printed in the terminal that ends with an “=” and paste it in the Key Hash field in Facebook. Then click the Save Changes button.

Reference: Integrate Facebook logins in your Android app

Solution 2:

Please follow below steps to find debug.keystore and generate key hash for android development at mac.

  1. Open terminal

  2. Type cd ~/.android and hit enter to go to .android directory

  3. If you want to open .android directory in finder, type open . and hit enter. Then .android directory will be opened in finder where you can find debug.keystore. If you do not want to open .android directory and only want to generate key hash, then skip this point and follow #4.

  4. In terminal where you are already in .android directory type

    keytool -exportcert -alias alias_name -keystore sample_keystore.keystore | openssl sha1 -binary | openssl base64

    and hit enter.

  5. You are asked for password. Enter android as password and hit enter. Then you get key hash ending with "="

  6. Copy key hash,enter in your facebook app setting page and save changes.

Solution 3:

Never did it on Mac before, but here are some advices:

1.You need OpenSSL. Install it. In Windows I just extract zip file, then copy three file include openssl.exe in bin folder to jdk's bin folder (where keytool is), don't know how it work on Mac.

2.Copy file keystore what you want to get key hash to jdk's bin folder. My keystore is debug.keystore (because I'm still in test, I don't want to use the main keystore).

3.Using command line to go to jdk's bin folder (In Windows, I just Run -> cmd -> type cd %JAVA_HOME%)

4.Type this command: keytool -exportcert -alias alias_name -keystore sample_keystore.keystore | openssl sha1 -binary | openssl base64

In my case (debug.keystore): keytool -exportcert -alias androiddebugkey -keystore debug.keystore | openssl sha1 -binary | openssl base64 then enter password for debug.keystore: android (without password, the key hash's still generated and the same as with password, don't know why).

You'll get some string with "=" character at the end. Go to your app setting -> mobile -> fill that key hash (include "=") to Android key hash.

Solution 4:

(honestly, not an answer, just a note for all visitors having this or similar trouble)

There is a way to obtain a key hash without JDK and OpenSSL by using pure Java utility android-fb-keytool. You can checkout and build source code.

Solution 5:

On a Mac, for generating a key hash, follow the simple steps below.

  1. Open Terminal
  2. Paste Below Command (Step 3) And Hit Return
  3. keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64
  4. Enter Password : Android
  5. It will give you Key hash (like MibyjIEJWghOLquRdk9esClXHWH=)
  6. This will give you a debug key hash. Also we can generate a Release key hash with the same Process. Just need to change our keystore path and password.

Happy Coding. Thank You

Post a Comment for "How To Generate Key Hash For Facebook Sdk In Mac"