Facebook key hash does not match any stored key hashes

AndroidFacebookFacebook Android-SdkFacebook Sharer

Android Problem Overview


I'm really having troubles with the Facebook hash key. I generated it in my Eclipse.. proof: http://imgur.com/jZBoTTc"><img src="http://i.imgur.com/jZBoTTc.png" title="Hosted by imgur.com" />

Then I went to https://developers.facebook.com/ and registered a new app. http://imgur.com/YY2WMvg"><img src="http://i.imgur.com/YY2WMvg.png" title="Hosted by imgur.com" /> http://imgur.com/bCMUIvW"><img src="http://i.imgur.com/bCMUIvW.png" title="Hosted by imgur.com" />

And finally I've set my hashkey at the settings of Facebook developers: http://imgur.com/G7Amm1f"><img src="http://i.imgur.com/G7Amm1f.png" title="Hosted by imgur.com" />

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

Android Solutions


Solution 1 - Android

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.

Solution 2 - Android

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

DATE: 16/05/2022 (16th of May 2022)

This is how I solved this problem

  1. I have got the SHA1 from signingReport

(found in gradle-->app/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.

Solution 3 - Android

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!

Solution 4 - Android

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

Solution 5 - Android

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

Solution 6 - Android

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.

Solution 7 - Android

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

  1. in android studio in right panel Gradle>App>android>signingReport copy SHA1
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.

Solution 8 - Android

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.

Solution 9 - Android

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.

Solution 10 - Android

  1. Check your Key hash value.
  2. Uninstall the Facebook application from your phone.
  3. Then try again using SDK.

This solved my problem.

Solution 11 - Android

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

Solution 12 - Android

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

Solution 13 - Android

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

Solution 14 - Android

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 ...

Solution 15 - Android

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")); 

Solution 16 - Android

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.

Solution 17 - Android

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();
        }
    }

Solution 18 - Android

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

Solution 19 - Android

For Windows Only:

At first I used "openssl-0.9.8k_X64.zip" for generate hash of key. This problem appears.

Then I used the openssl version "openssl-0.9.8e_X64.zip" in windows. Then the problem solved.

https://code.google.com/archive/p/openssl-for-windows/downloads

I think most of us having same problem.

Solution 20 - Android

For signing the developer build, you will use the keystore and key generated by Android Studio. You can retrieve this with the following command:

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

Thanks

Solution 21 - Android

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

Solution 22 - Android

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.

Solution 23 - Android

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.

Solution 24 - Android

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

Solution 25 - Android

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

Solution 26 - Android

@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);

Solution 27 - Android

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

Solution 28 - Android

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

Solution 29 - Android

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.

Solution 30 - Android

What worked in my case:

Solution 31 - Android

The best solution is to get your APK file, Use the keytool to get your app's signature as follows:

C:\Program Files\Android\jdk\microsoft_dist_openjdk_1.8.0.25\bin> ./keytool -list -printcert -jarfile myapp.coolapp.apk

In my case, my apk was placed in the same directory as the keytool, I later deleted it. After running the above command, you have a list of keys, copy the SHA1 key Convert it to base64 using this tool Copy the Base64 conversion, Go to facebook dev portal, navigate to your app, then "settings/basic" Then go to the key hashes section. Paste the Base64 hash there, and facebook login will work just fine.

Here is an article that explains these steps in detail:

Solution 32 - Android

For me what eventually worked was to use the debug.keystore that is stored inside the android/app folder. So basically running the keytool command from the app folder like that:

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

The password is: android

Solution 33 - Android

I faced this issue. Then I uninstalled my Facebook App. Then it is opening with my default browser. Then the login/signup was succeeded via facebook.

Solution 34 - Android

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionYentheView Question on Stackoverflow
Solution 1 - AndroidNarender GusainView Answer on Stackoverflow
Solution 2 - AndroidMoustafa EL-SaghierView Answer on Stackoverflow
Solution 3 - AndroidYentheView Answer on Stackoverflow
Solution 4 - AndroidKewal ShahView Answer on Stackoverflow
Solution 5 - AndroidBashar Ali LabadiView Answer on Stackoverflow
Solution 6 - AndroidDarsen LuView Answer on Stackoverflow
Solution 7 - AndroidGovanView Answer on Stackoverflow
Solution 8 - AndroidvvbYWf0ugJOGNA3ACVxpView Answer on Stackoverflow
Solution 9 - AndroidPratap SharmaView Answer on Stackoverflow
Solution 10 - AndroidRezaul KarimView Answer on Stackoverflow
Solution 11 - AndroidThamimView Answer on Stackoverflow
Solution 12 - AndroidEvanView Answer on Stackoverflow
Solution 13 - AndroidsakramentoView Answer on Stackoverflow
Solution 14 - AndroidAleksey TimoshchenkoView Answer on Stackoverflow
Solution 15 - AndroidKetan RamaniView Answer on Stackoverflow
Solution 16 - AndroidtnaughtView Answer on Stackoverflow
Solution 17 - AndroidSandeep.RView Answer on Stackoverflow
Solution 18 - AndroidLeo NguyenView Answer on Stackoverflow
Solution 19 - AndroidiamcrypticcoderView Answer on Stackoverflow
Solution 20 - AndroidMir MahfuzView Answer on Stackoverflow
Solution 21 - AndroidMuhammad AsyrafView Answer on Stackoverflow
Solution 22 - AndroidDinesh VermaView Answer on Stackoverflow
Solution 23 - AndroidRamonView Answer on Stackoverflow
Solution 24 - AndroidTausif Ul RahmanView Answer on Stackoverflow
Solution 25 - AndroidEimiharView Answer on Stackoverflow
Solution 26 - AndroidAgentPView Answer on Stackoverflow
Solution 27 - AndroidIrfandi D. VendyView Answer on Stackoverflow
Solution 28 - AndroidIancu VladView Answer on Stackoverflow
Solution 29 - AndroidJay KundaliyaView Answer on Stackoverflow
Solution 30 - AndroidPablitoView Answer on Stackoverflow
Solution 31 - AndroidDamien DoumerView Answer on Stackoverflow
Solution 32 - Androiduser3752382View Answer on Stackoverflow
Solution 33 - AndroidGk Mohammad EmonView Answer on Stackoverflow
Solution 34 - AndroidShubham GuptaView Answer on Stackoverflow