77

I'm really having troubles with the Facebook hash key. I generated it in my Eclipse.. proof:

Then I went to https://developers.facebook.com/ and registered a new app.

And finally I've set my hashkey at the settings of Facebook developers:

But no whatter I do I keep getting the same error log: "Key hash B5dWUEYfZJL/...........jyA= does not match any stored key hashes"

Does anybody know what I did wrong or how I can fix this problem? If I used the id and name from the HelloFacebookSample inside my own app everything works. So it HAS to do with the key hash, id or name I've set somewhere most likely..

Thank you, Yenthe

Yenthe
  • 1,997
  • 2
  • 21
  • 44
  • 1
    The screen cap where you're showing the key hash settings is the wrong place. "Sample App Settings" is only for key hashes for the sample apps that ship with the SDK (so you can build them locally). You should put the key hashes under the "Android" tab in your app settings. – Ming Li Nov 30 '13 at 19:38
  • Yeah I know what you mean and that was my initial fault. I then moved it to the Android tab, but neither that was a succes. I had to manually remove my hash key and generate a new one before it all started working. – Yenthe Dec 01 '13 at 09:08
  • delete your app from developers.facebook.com and try this http://stackoverflow.com/questions/4388992/key-hash-for-android-facebook-app/6665263#6665263 – Manmohan Pal Feb 26 '17 at 06:41

29 Answers29

80

If your login is working without installing facebook app and not working when facebook app is installed due to error "hash key has not match" then do following steps

1 ) Launch your app and try to log in with facebook. A dialog will open and tell you: "the key has not been found in the facebook developer console and also show the hash key.

2 ) Note down that hash key.

3 ) Put it into your facebook developer console where you first generated your api key and remove the hash key with new and save. Now you are done. Anyone that downloads your app, published with earlier used keystore can log into facebook.

Narender Gusain
  • 1,801
  • 11
  • 13
45

After hours of trying I've finally found a solution.

  1. Delete any app on the website of Facebook (developers.facebook.com)
  2. Delete the file debug.keystore under C:\Users\yourUserName\.android
  3. Generate a new key (by running your app again)
  4. Create a new app on developers.facebook.com and add the new hash key
  5. Re-run your app
  6. Succes!
Jorgesys
  • 114,263
  • 22
  • 306
  • 247
Yenthe
  • 1,997
  • 2
  • 21
  • 44
  • Thanks! This really works but what if I have a couple of apps registered on the Developers site of Facebook and this issue comes over and over again from time to time? – Yulian Jan 08 '15 at 13:20
  • @Yulian I'm not sure, that sounds like a very annoying problem.. I'm not sure about this as I only have one app on the Developers site. Sorry! – Yenthe Jan 08 '15 at 13:23
  • Good to hear that my solution is still working @FernandoP.G.! I'm amazed too that this error is still here after over a year.. – Yenthe Feb 18 '15 at 15:07
  • 94
    Now what do we do if we already have thousands of users, just recreating the app isn't exactly a great idea. – Hobbyist May 13 '15 at 12:34
  • My Review got success. If I create a new app then again I want to submit for review. Is creation new app is mandatory? – Naveen Kumar M Aug 27 '16 at 05:54
  • Saved my day. Had the same issue. Just changing current FB app with new app solved every thing. Thanks – Rahul Oct 28 '16 at 07:15
  • I have very similar situation to yours. I didn't remove everything, but created new license, went to my regular FB page - Settings - Apps - Removed the app from the list. Changed hash key in dev account and reinstalled fb app and own app. And now it works...It seems fb "remembers" hash keys. – anna_manzhula Jun 07 '17 at 11:46
  • 7
    Deleting apps is not an option, This solved the problem https://github.com/AntonioCuevaUrraco/nativescript-facebook-login/issues/14 – Mustafa Magdy Apr 17 '18 at 03:31
  • 1
    Regenerating `debug.keystore` can complicate matters as if you are using firebase with Google Sign-In it will no longer work as a new SHA-1 key will be generated and you would have to update it in your firebase app page – Kewal Shah Jun 08 '18 at 09:44
  • What about apps that are already on the store and that have users already using facebook? You can't just delete the app. – skydev Oct 31 '18 at 14:07
  • I have the same error but when I didn't set any password in "Enter keystore password:" (Leave it blank and just hit Enter) then it works. It gives some warning but it works – Erfan Jazeb Nikoo Dec 02 '18 at 12:39
  • I have permissions on the app, it would be a a long process to get things in order again if I remove it – Tushar Gogna Mar 18 '19 at 07:55
37

I faced the same issue while development and needed to get the hash key to test sharing on facebook, and while solving this I went through couple of issues

1- the command facebook provide to get the hash key by using openSSL command didn't give me the right hash that I got by extracting the signature from Package info with code. getting the hash by the second way was correct.

2- For some reason, In the documentation they tell you to go to developer settings and add the hash key for 'Sample App' there, I thought every hashkey for a developer should be there, and that was my mistake, every app has it's own hash keys field to add to, go to your app/settings/android.

enter image description here

well that was it.. and for the records I used openssl-0.9.8k_X64 on a Windows 7 x64 bit and it just generates a wrong hash I don't know why

I used this code to get the hash:

private void printKeyHash() {
    // Add code to print out the key hash
    try {
        PackageInfo info = getPackageManager().getPackageInfo("YOUR PACKAGE NAME", PackageManager.GET_SIGNATURES);
        for (Signature signature : info.signatures) {
            MessageDigest md = MessageDigest.getInstance("SHA");
            md.update(signature.toByteArray());
            Log.d("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
        }
    } catch (NameNotFoundException e) {
        Log.e("KeyHash:", e.toString());
    } catch (NoSuchAlgorithmException e) {
        Log.e("KeyHash:", e.toString());
    }
}

but be careful that this may not also print in logs the correct keyhash, at least on my device and machine, when I debug it, in a watch it shows the correct hash just before printing the logs, but in logs it shows another hash and the first one was the correct one.

anyway you can also use a command or eclipse to view the SHA hexadecimal sequence for your key and convert it to base 64 online, there are websites that may help http://tomeko.net/online_tools/hex_to_base64.php?lang=en

Good luck

Bashar Ali Labadi
  • 854
  • 1
  • 8
  • 16
  • this one did it for me! thanks buddy! i added that code into my oncreate function for my mainactivity and check the result in my logcat console, filtered by "KeyHash" and got that key pasted in my app dashboard, it worked perfectly ! – Fo Nko May 27 '18 at 23:11
  • i sent my app to a friend, and he has the same issue... it's wokring for me but he can't log ! why is that? – Fo Nko May 28 '18 at 00:10
36

I encountered a similar problem. The solution is surprisingly simple.

The error message looks like this:

07-05 ...... Invalid key hash. The key hash sL1***************VY= does not match any stored key hashes. Configure your app key hashes at http://developers.facebook.com/apps/150*******778
07-05 ......     at com.facebook.login.LoginManager.onActivityResult(LoginManager.java:191)

Simply log into https://developers.facebook.com , select the "Settings" tab, and add the key hash "sL1***************VY=" to the list of saved Key hashes in the Android panel.

Darsen Lu
  • 573
  • 6
  • 10
35

DATE UPDATED EVERY TIME I GOT UPVOTE AS I KNOW IT STILL VALID

DATE: 29/05/2021 (29th of May2021)

This is how I solved this problem

  1. I have got the SHA1 from signingReport

(found in gradle-->tasks/android/signingReport)

Copy the SHA1 value to your clipboard

like this XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX

  1. Facebook sdk requires it to be in base64 hash key so we open http://tomeko.net/online_tools/hex_to_base64.php

to convert your SHA1 value to base64.

This is what Facebook requires get the generated hash " ********************= "

  1. open https://developers.facebook.com/

  2. select your project in the setting tab, basic/Key Hashes add the generated key.

  3. don't forget to save changes.

34

This is a case that could have possibly occurred and what solved my error:

In the https://developers.facebook.com/quickstarts after you run

OSX/Linux:

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

Windows:

keytool -exportcert -alias androiddebugkey -keystore %HOMEPATH%\.android\debug.keystore | openssl sha1 -binary | openssl base64

When Enter keystore password: is asked you may have accidentally typed a wrong password, the default password is "android". Typing any other password will give you a different/wrong hash key. Paste the correct hash key in the Key Hashes field on your app page

This solved my problem, hope this helps whoever made this particular error that I made

Kewal Shah
  • 691
  • 11
  • 24
  • Is it possible to change the default password? if so how\where? – Coder123 Jan 02 '19 at 16:02
  • @Coder123 just create your own `debugAlt.jks` in another directory with different password and key and put it in your `signingConfigs { debug { storeFile file(new File('../debugKey.jks')) storePassword "Qwerty123" keyAlias "debug" keyPassword "Qwerty123" } }` – Variag Jan 10 '19 at 21:52
  • you mean we should compulsorily use "android" as password? where is it written? – user1090751 Jan 23 '20 at 15:00
  • @user1090751 click on the "android" link in my answer for more details. You can create your own password as pointed out in the previous comment – Kewal Shah Jan 24 '20 at 10:12
  • Thank you for this password! That solved it for me! – ljubiccica Mar 20 '20 at 16:12
18

---2019----- This is how i solved this problem

  1. in android studio in right panel Gradle>App>android>signingReport copy SHA1
  2. and open http://tomeko.net/online_tools/hex_to_base64.php to convert your SHA1 value to base64.

This is what Facebook requires get the generated hash " ********************= " and copy the key hash to the facebook app.

Community
  • 1
  • 1
Govan
  • 940
  • 1
  • 10
  • 11
17

Adding SHA1 keys from Eclipse/keytool helped me only when creating the app on FB, then after rebuilding I would always get the OP error.

What solved my issue was adding the key in the error message to the Facebook dashboard settings.

Peter File
  • 975
  • 9
  • 22
9
  1. Check your Key hash value.
  2. Uninstall the Facebook application from your phone.
  3. Then try again using SDK.

This solved my problem.

Pang
  • 8,605
  • 144
  • 77
  • 113
Rezaul Karim
  • 1,126
  • 17
  • 25
9

While generating release Hash key, Note this

For Windows

When generating the hash key for production you need to use openssl-0.9.8e_X64.zip on windows, you cannot use openssl-0.9.8k_X64.zip

The versions produce different hash keys, for some reason 9.8k does not work correctly... 9.8e does.

OR

Use this below flow

This is how i solved this problem Download your APK to your PC in java jdk\bin folder in my case C:\Program Files\Java\jdk1.7.0_121\bin go to java jdk\bin folder and run cmd then copy the following command in your cmd

keytool -list -printcert -jarfile yourapkname.apk

Copy the SHA1 value to your clip board like this CD:A1:EA:A3:5C:5C:68:FB:FA:0A:6B:E5:5A:72:64:DD:26:8D:44:84 and open http://tomeko.net/online_tools/hex_to_base64.php to convert your SHA1 value to base64.

For MAC

Step 1:

Generate SHA1 key by using below command
keytool -list -v -keystore Keystore path
Enter Keystore password.
Copy SHA1 Key.

Step 2:
Open this link - http://tomeko.net/online_tools/hex_to_base64.php
Paste the SHA1 Key in Hex String
Click convert button
Get the Release Keyhash in Output value

Thamim
  • 298
  • 3
  • 12
9

Follow these steps in order to generate the correct key hashes.

  1. Open your project in android studio and run the project.
  2. Click on Gradle menu.
  3. Select your app and expand task tree.
  4. Double click on android -> signingReport and see the magic Sample Image
  5. Result after clicking above tab Result after clicking above tab
  6. Copy the SHA1 key and browse SHA1 key to key hash
  7. After converting the SHA1 key to key hash copy the new key hash and paste it in facebook console. This will work like charm.
Pratap Sharma
  • 1,645
  • 1
  • 13
  • 23
7

I have had this Problem for two months now. My key hashes have been pyling up to 9. Today i finally found the simple solution:

STEP 1:

Install the facebook sdk you downloaded from the facebook developer page on your phone. Don´t install the normal facebook app. Make sure you can log into facebook. Then log out.

STEP 2:

Export your app with your final release key as an apk, like you would when uploading it to the playstore.

STEP 3:

Put the Apk file on your phone via usb cable or usb stick.

STEP 4:

Install your app, using a file manager: For example https://play.google.com/store/apps/details?id=com.rhmsoft.fm

STEP 5:

Launch your app and try to log in with facebook. A dialog will open and tell you: "the key has not been found in the facebook developer console

STEP 6:

Write down the key.

STEP 7:

Put it into your facebook developer console and save. Now you are done. Anyone that downloads your app, published with earlier used keystore can log into facebook.

Enjoy

Sakramento
  • 299
  • 4
  • 14
  • am fallowing your tips pasted that facebook-universalsignin.apk in to mobile and istalled that.and then my app install and runned in that situation also facebook popup openned for login no other dialog box coming please help me – Harsha Nov 08 '16 at 13:22
  • Did you install the facebook sdk form the developer page and uninstall the normal facebook app from the playstore? – Sakramento Jan 06 '17 at 14:51
6

It is looks crazy but it work

Really issue because of you privite facebook account got this app and hash key of this account does't comparable

But you musn't to faced this error with real user. But I am not sure

Eventually follow next step :

  1. Go to your private facebook account which you try to log in
  2. Then click More in app dir

enter image description here

  1. Click Settings

enter image description here

And then click cross

enter image description here

And now you can login with facebook. But next time if you log out and than will try log in again you faced with the same issue...

It is also weird...

But I don't bellieve that facebook don't know about this ...

Aleksey Timoshchenko
  • 3,364
  • 1
  • 33
  • 61
6

This worked for me

  1. Go to Google Play Console
  2. Select Release Management
  3. Choose App Signing
  4. Convert App-Signing Certificate SHA-1 to Base64 (this will be different than your current upload certificate) using this tool: http://tomeko.net/online_tools/hex_to_base64.php?lang=en
  5. Enter Base64 converted SHA-1 into your Facebook Developer dashboard settings and try again.

your Google Play SHA-1

Evan
  • 87
  • 1
  • 7
5

I am also getting the same issue when user try to Login with Facebook.

Not Working: Facebook App is Installed in Device.

Working: Facebook app is not installed

So, following Code is resolved the issue event the Facebook app is installed in device.

LoginManager.getInstance().setLoginBehavior(LoginBehavior.WEB_ONLY); //This Line Solved Issue
LoginManager.getInstance().logInWithReadPermissions(context, Arrays.asList("public_profile", "email")); 
Community
  • 1
  • 1
Ketan Ramani
  • 3,300
  • 24
  • 36
4

What I found was that my SHA-1 that was used to sign the app to be uploaded to the Google Playstore was not correct. I realized that my app was being signed by the Google Play Store with a different token. I followed these steps:

  1. Go to Google Play Console
  2. Click Release Management
  3. Click App Signing
  4. Convert App-Signing Certificate SHA-1 to Base64 (this will be different than your current upload certificate)
  5. Enter Base64 converted SHA-1 into my Facebook Developer dashboard settings

    I am now able to log into my app when the Facebook is downloaded on and Android device.

tnaught
  • 271
  • 4
  • 13
3

Using Debug key store including android's debug.keystore present in .android folder was generating a strange problem; the log-in using facebook login button on android app would happen perfectly as desired for the first time. But when ever I Logged out and tried logging in, it would throw up an error saying: This app has no android key hashes configured. Please go to http:// ....

Creating a Keystore using keytool command(keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -sigalg SHA1withRSA -keysize 2048 -validity 10000) and putting this keystore in my projects topmost parent folder and making a following entry in projects build.gradle file solved the issue:

 signingConfigs {
        release {
            storeFile file("my-release-key.keystore")
            storePassword "passpass"
            keyAlias "alias_name"
            keyPassword "passpass"
        }    }

Please note that you always use the following method inside onCreate() of your android activity to get the key hash value(to register in developer.facebook.com site of your app) instead of using command line to generate hash value as command line in some cased may out put a wrong key hash:

    public  void showHashKey(Context context) {
        try {
            PackageInfo info = context.getPackageManager().getPackageInfo("com.superreceptionist",
                    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("KeyHash:", sign);
                //  Toast.makeText(getApplicationContext(),sign,     Toast.LENGTH_LONG).show();
            }
            Log.d("KeyHash:", "****------------***");
        } catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
        } catch (NoSuchAlgorithmException e) {
e.printStackTrace();
        }
    }
Sandeep.R
  • 61
  • 1
3

I got the same problem. I found that I used wrong hashkey. keytool printed wrong hashkey because I run command with wrong alias.
Please check your command again.It will resolve your issue

keytool -exportcert -alias "test fb sdk" -storepass android -keypass android -keystore "C:\keystore.keystore" | openssl sha1 -binary | openssl base64
Leo Nguyen
  • 604
  • 1
  • 9
  • 23
1

I got simular problem. After signing and publishing my app to the google PlayStore it seems the Hash has changed. I added the new Hash (as mentioned) in the Facebook messaged to the Key Hashes in my app on developers.facebook.com/app//settings. Now it works again.

Ramon
  • 101
  • 1
  • 4
1

You are may be using wrong password the default password for debug keystore is android

1

My problem is possibly due to the hash got wrongly generated by the openssl itself, if anyone is facing similar problem using the method provided by the facebook android guide itself.

One way to deal with this is :

  1. Get your sha1 using this tool :

keytool -exportcert -keystore path-to-debug-or-production-keystore -list -v

  1. convert it to base64 using this tool

http://tomeko.net/online_tools/hex_to_base64.php

credit :

https://github.com/facebook/react-native-fbsdk/issues/424#issuecomment-469047955

Eimihar
  • 115
  • 1
  • 6
0

@Ketan Ramani answer helped me but in my case, I was not using the LoginManager instead I was registering a callback on an image if you are using registerCallback on any image by making it a login button use below code

 loginButton.setLoginBehavior(LoginBehavior.WEB_ONLY);
AgentP
  • 3,133
  • 2
  • 15
  • 27
0

I have tried everything on this page but no success, until i took a break, then when I continue working on this, without changing anything, it suddenly works. Maybe (just maybe) facebook needs times to register the key

Irfandi D. Vendy
  • 594
  • 9
  • 18
0

Here is Nice Solution for macOs And It works for me :

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

Here key store password should be android . Thanks

Mir Mahfuz
  • 221
  • 2
  • 7
0

In the right side of Android Studio go to Gradle -> Tasks -> android -> signingReport and run it. Copy the SHA-1 key and transform it into base64 using this, and then add the converted base64 hash to your app in the Facebook Developer Console. If you want to use a release hash run this in the command line:keytool -exportcert -alias YOUR_KEYSTORE_ALIAS -keystore YOUR_KEYSTORE | openssl sha1 -binary | openssl base64 Where YOUR_KEYSTORE is the path to the .keystore or .jks that you used as signinConfig for your release variant and YOUR_KEYSTORE_ALIAS is the alias which you gave when you created the keystore. If you do not remember the alias you can run keytool -v -list -keystore YOUR_KEYSTORE and see all the info about the keystore

Iancu Vlad
  • 31
  • 2
  • 2
0

On Debug

Copy Paste This code inside OnCreate method

       try {
            PackageInfo info = getPackageManager().getPackageInfo(
                    getApplication().getPackageName(),
                    PackageManager.GET_SIGNATURES);
            for (Signature signature : info.signatures) {
                MessageDigest md = MessageDigest.getInstance("SHA");
                md.update(signature.toByteArray());
                Log.d("KeyHash", Base64.encodeToString(md.digest(), Base64.DEFAULT));
            }
        } catch (PackageManager.NameNotFoundException e) {
            Log.d("KeyHash e1",e.getLocalizedMessage() +"");
        } catch (NoSuchAlgorithmException e) {
            Log.d("KeyHash e2", e.getLocalizedMessage() +"");
        }

Open Logcat and Filter/find 'D/KeyHash:'

D/KeyHash: D5uFR+65hafzotdih/dOfp14FpE=

Then Open https://developers.facebook.com/ and Open YourApp/Setting/Basic
Scroll down to Android Section Then Paste the Key Hashes and Save

Muhammad Asyraf
  • 1,320
  • 11
  • 17
0

Just run command adb logcat | grep hash and look for something like Key hash ABCDEFGH1234= does not match any stored key. Now save this hash on your fb developer console.

Dinesh Verma
  • 406
  • 2
  • 8
0

I have same problem when I so facebook integration, and I solved this error by this steps:

  1. open android folder(File/open/yourFlutterProject/android) in your flutter project
  2. now you can see gradle field in right-side top penal -------Gragle Image
  3. do this steps(gradle/android/app/tasks/android/signingReport) and click it.
  4. now you can see your project SHA-1 key, note it.
  5. now open this site(Site Link) and convert SHA-1 to keyhash and you get your keyhash value, note it.
  6. not update/change this keyhash with currunt keyhash in your developer.facebook console
  7. now its run perfect.
-2

Check your google-services.json . May be it is different one. Download your latest google-services.json and then run the app. Hope it helps.

Shubham Gupta
  • 95
  • 1
  • 4