86

I have problem about login with facebook acount in my application. I read to Facebook Doc. And I did all step as Facebook Doc.

First in login with facebook acount in app - SUCCESSFUL ! and than logout in application. I want to login again with my facebook acount. But not working !! And I took this Excepiton ! Please help me !

Exception : This app has no Android Key hashes configured.Configure your app key hashes at http:developers.facebook.com/apps/"APP ID"

Finaly; I used to part of code for HashKey Genarate

 try {
        PackageInfo info =     getPackageManager().getPackageInfo("MY PACKAGE NAME",     PackageManager.GET_SIGNATURES);
        for (android.content.pm.Signature signature : info.signatures) {
            MessageDigest md = MessageDigest.getInstance("SHA");
            md.update(signature.toByteArray());
            String sign=Base64.encodeToString(md.digest(), Base64.DEFAULT);
            Log.e("MY KEY HASH:", sign);
          //  Toast.makeText(getApplicationContext(),sign,     Toast.LENGTH_LONG).show();
        }
} catch (NameNotFoundException e) {
} catch (NoSuchAlgorithmException e) {
}

I resolved my issue. I should have done setting on Facebook. Steps :

  1. Go to facebook developer's page : https://developers.facebook.com/
  2. Open the App tabs and than click the Setting

  3. Paste the generate hashkey on HashKey's field = If you don't have it yet, get your key hash part of code

  4. And than Single Sign On will be "Yes" : Single Sign On: Enable this setting.

I wanted to share my resolve. Maybe someone need this solution. Good Luck !

5
  • 1
    Thanks - you assisted me and I had experienced the same problem +1
    – Simon
    Commented Apr 29, 2015 at 17:27
  • Facebook provides now very good quick start explanation how to generate hashes, after you click on the settings button and add a new platform: For Mac: keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64 For Windows: keytool -exportcert -alias androiddebugkey -keystore %HOMEPATH%\.android\debug.keystore | openssl sha1 -binary | openssl base64
    – FilipR
    Commented Jul 8, 2015 at 18:55
  • How did you resolve this issue?
    – andrei
    Commented Jul 28, 2015 at 16:26
  • 3
    You should post your solution as answer instead, and marking it as an answer. This will stop showing this question as unanswered.
    – Sufian
    Commented Sep 15, 2015 at 10:13
  • Does this is will be produced in debug or development mode or it will be available for production as well while login the app. I am able to login the app without any error. now it showing the key hash error with my tester account. Does the same will occured if i move to the live mode for all other users.
    – sejn
    Commented Nov 22, 2021 at 8:08

5 Answers 5

16

You need not generate your hash key. When you will try to access facebook from your app, you will get an error msg saying following "[Hash Key]" is not registered or configured. Just copy that key and go to developer.facebook.com where you have registered your app for facebook verification and include under key hashes.

Remember : For every device, the hash key may be different. You need to include it freshly.

By default this key should do : 2jmj7l5rSw0yVb/vlWAYkK/YBwk=

Also, before everything, you need to provide facebook with your App details, along with screenshots of where you are using facebook features and reasons for why you are using. They need to verify that.

3
  • Thanks Nielarshi for your answer. But I resolved another way. Commented Dec 14, 2014 at 13:17
  • 2
    @TarıkYurtlu What is it? I've registered the hash key but it didn't work. If I uninstall facebook app it will work. Should I register application for release or we can do it for development?
    – Amt87
    Commented Mar 17, 2015 at 9:58
  • 4
    Old thread, but... Isn't the key different for each "signed apk version" and not for each device? Surely, if it was for each device, nobody would be able to use it. Hint to others: The hash key between the signed version you upload and the one you use when just developing are different. Though you can add multiple hash keys in facebook, so should not be a problem. The moment you use another signing key the hash will change.
    – renevdkooi
    Commented Oct 22, 2015 at 2:15
10

To generate a hash of your release key, run the following command on Mac or Windows substituting your release key alias and the path to your keystore. On OS X, run:

keytool -exportcert -alias <RELEASE_KEY_ALIAS> -keystore <RELEASE_KEY_PATH> | openssl sha1 -binary | openssl base64

On Windows, use:

keytool -exportcert -alias <RELEASE_KEY_ALIAS> -keystore <RELEASE_KEY_PATH> | openssl sha1 -binary | openssl base64


Ref: https://developers.facebook.com/docs/android/getting-started/#create_hash

1
  • I already have the SHA keystore in my app. Shall I need to add that key in the facebook as well?
    – sejn
    Commented Nov 22, 2021 at 11:09
4

If you haven't published your app and just want to use the debug version hash, you can get it from your debug keystore with this command:

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

More on this related SO post

2

There is a easy way to get your Hash Key.

Just put in your main .kt file, in onCreate method, the following lines:

FacebookSdk.sdkInitialize(this)
println("Facebook hash key: ${FacebookSdk.getApplicationSignature(this)}")

Then copy the result to facebook developers website. Sometimes the result doesn't have the equal symbol (=) at the end of the generated string. If so, add it manually.

1
# Get all Hash Expo  
expo fetch:android:hashes

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