Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid key hash. The key hash does not match any stored key hashes. #297

Closed
francisrod01 opened this issue Jan 18, 2018 · 55 comments
Closed

Comments

@francisrod01
Copy link

francisrod01 commented Jan 18, 2018

I generate the key hash from android keystore following Facebook docs:

https://developers.facebook.com/docs/android/getting-started/#release-key-hash

So.. I implemented all of this lib needs to and I received this error message in my emulator:

invalid_key_hash

The problem is that key hash is not my key hash generated and saved in the facebook developers app configurations.

I make a test: put this "new" key hash in facebook developers key hashes too and tried again and I was able to login successfully.

My doubt is: WTF's going on with this key hashes?
Please I need your help with this.

@nguyenvanphuc2203
Copy link

add key hash in message error to app setting 🗡️

@francisrod01
Copy link
Author

The problem is that key hash is not my key hash generated and saved in the facebook developers app configurations.

This key hash it was add in facebook app settings but it is not my key hash.

@saimonventura
Copy link

I'm having the same problem.
As did what ma7modtaweelz talk about but the key was the same I get from the facebook mode.

if you can resolve this, plz post, I want to now to.

@saimonventura
Copy link

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.

@delw
Copy link

delw commented Apr 20, 2018

@saimonventura what do you mean by step 3? I copied the key hash that the error was showing me and replaced it with the one in the facebook app but it still shows me the same error.

@francisrod01
Copy link
Author

I make a test: put this "new" key hash in facebook developers key hashes too and tried again and I was able to login successfully.

The problem is that key hash is not my key hash generated and saved in the facebook developers app configurations.

@saimonventura Does you continues do use this hash key in your facebook developer as production? 0.o

This is a security fail and needs to be solved!

@cristianPerez
Copy link

cristianPerez commented Apr 29, 2018

Firebase Facebook Login Hash Keys Issue

Hi, guys.
Regards from Colombia, I'm gonna ask you about this problem because today it was kicking my head.

I was working with firebase facebook auth into the react-native app, my problem is the same "key hash".

I thought this link should help me, but I did everything and the result is the same problem.
https://developers.facebook.com/docs/facebook-login/android/advanced

Another issue related:
https://goo.gl/Myd38Q

For this reason, I need to stay here as an active subscriber if anybody finds the solution, please reach out here.

this is my email: [email protected]

I will try to solve this problem.

SOLVED::::::

The solution just avoids closing facebook session, in develop when you will be in production this problem desapeears.

@francisrod01
Copy link
Author

francisrod01 commented May 15, 2018

I think you guys didn't understand the bug here.

This is how to show up the hashkey:

~$ keytool -exportcert -alias my-key-alias -keystore my-release-key_pkcs12.keystore | openssl sha1 -binary | openssl base64
Enter keystore password: xxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxx=

See more details: https://stackoverflow.com/a/7506445/3332734

Go to Facebook Developers and set the hash key to Settings > Basic - add Android platform and put the key in Key Hashes field and save it.

BUT the problem is to authenticate after this configuration.

In the RN the authentication returns error message containing the key hash yyyyyyyyyyyyyyyyy= does not match any stored key hashes.

I set the xxxxxxxxxxxxxxxxx= key hash in Facebook Developers, but returns me a error message with a yyyyyyyyyyyyyyyyy= key hash. I mean, a different key hash setted in FB Developers.

The thing that should be different here:

1 + 1 = 2 (mathematic)
1 + 1 = 10 (binary)

@bleedweedsuz
Copy link

i have the same error but when i didn't set any password in "Enter keystore password:" [here i just hit enter] then it works O.O
it give me some warning but it works (literally just now 😆 )

@ulrick
Copy link

ulrick commented May 22, 2018

I also had the same problem. I just emptied the cash and the app data on my phone after making sure to follow the whole procedure again

@ulrick
Copy link

ulrick commented May 22, 2018

it may also be necessary to add the key mentioned in your error in the "hash keys" field of the interface facebook for developper

@francisrod01
Copy link
Author

I'm not use this lib anymore.
I'll try with a clean project this month.

@akyGit
Copy link

akyGit commented May 29, 2018

Please note, two types of key hashes exist: debug and release.

If you use react-native run-android: debug key hash will be used.
If you use ./gradlew assembleRelease and install app-release.apk: release key hash will be used

So, when you run keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64 you will see debug key hash

When you run keytool -exportcert -alias YOUR_RELEASE_KEY_ALIAS -keystore YOUR_RELEASE_KEY_PATH | openssl sha1 -binary | openssl base64 you will get release key hash

YOUR_RELEASE_KEY_ALIAS it's alias from gradle.properties (in most cases)
YOUR_RELEASE_KEY_PATH it's path to your release.keystore in your project (see gradle.properties file)

@madmax124
Copy link

madmax124 commented May 30, 2018

After trying every possible solution (with no luck), downloaded a hash key extractor app : https://apkpure.com/key-hash-key/notimeforunch.keyhash

Copy pasted the hash key using the app and no more invalid hash key errors.

@nucklearproject
Copy link

If the hash code has be changed, try delete the app from facebook.
https://www.facebook.com/settings?tab=applications&section=active

@yaibait
Copy link

yaibait commented Jul 28, 2018

@madmax124 thanks bro, your solution help me 💯

@edgargrs
Copy link

edgargrs commented Aug 2, 2018

@madmax124 thanks,
before they close this error,
Someone can explain me why the application that provides @madmax124
generates a different keyhash than the one generated by the console.
To generate the keyhash of an apk that I have already signed is the following
keytool -list -printcert -jarfile [path_to_your_apk] | grep -Po "(? <= SHA1 :). *" | xxd -r -p | openssl base64
that command gives me a different keyhash than the one generated by this app

The keyhash generated by the application helped me and there were no problems with facebook, but who knows the difference?

@hoekeat
Copy link

hoekeat commented Oct 2, 2018

but the point being, key hash is unique to devices, can someone confirm that is the nature of debug environment?

@VickySalunkhe
Copy link

VickySalunkhe commented Oct 29, 2018

This is how i solved this problem

Check Out my answer on stackoverflow
https://stackoverflow.com/a/54513168/9236994
(If this answer helps you do rate the answer on stackoverflow too Thankyou :) )

Or read here

first get you SHA1 from keystore file
keytool -list -v -keystore keystore_file_name.jks -alias key0

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.
This is what Facebook requires
get the generated hash " ********************= " and copy the key hash to the facebook app.

refer the image

@anismomin
Copy link

@VickySalunkhe thanks it works.

@javadoffuad
Copy link

javadoffuad commented Nov 13, 2018

capital i looks like as small L.
Сheck carefully.
screenshot_6

@knight1O1
Copy link

This is how i solved this problem

first get you SHA1 from keystore file
keytool -list -v -keystore keystore_file_name.jks -alias key0

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.
This is what Facebook requires
get the generated hash " ********************= " and copy the key hash to the facebook app.

refer the image

Solved mine too in Android Studio but with slight different approach.

To get the SHA-1 value in Android Studio.

  1. Click Gradle
  2. Click Signing Report
  3. Copy SHA-1

capture1

  1. went to website & Paste the SHA-1.
    Thanx ! Man !

@smileforandroid996
Copy link

@madmax124 thanks
can anyone know how this app work and get key hash ?
https://apkpure.com/key-hash-key/notimeforunch.keyhash

@RomuloDevelop
Copy link

I have the same issue today. Looks like it is an error of the openssl tool

@luatnd
Copy link

luatnd commented Mar 29, 2019

Exactly my issue, it ruins some of my hours.
My solution is "DO NOT USE PASSWORD" when you generating hashed key.

@pacozaa
Copy link

pacozaa commented Apr 2, 2019

@bleedweedsuz man you just save me. It works!

@UzairAhmedSiddiqui
Copy link

extending @VickySalunkhe answer.
for anyone wondering where does new hash which your app complains about after being published comes from.
facebookarchive/react-native-fbsdk#424 (comment)

@MMujtabaRoohani
Copy link

Was facing the same issue. Just realized that I was generating Android App Bundle so the app signing was managed by Google Play Console. Just use the SHA1 fingerprint from Play Console under App Signing to generate base64 hash and it will work.

@LosYondris
Copy link

@MMujtabaRoohani Thank you very much, it has worked for me.

@jagmel
Copy link

jagmel commented Jul 15, 2019

Recently found this Hasher App which helps in extracting keyhash from sha1 (from google play store console) and vice-versa

@robertwillian
Copy link

This is how i solved this problem
first get you SHA1 from keystore file
keytool -list -v -keystore keystore_file_name.jks -alias key0
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.
This is what Facebook requires
get the generated hash " ********************= " and copy the key hash to the facebook app.
refer the image

Solved mine too in Android Studio but with slight different approach.

To get the SHA-1 value in Android Studio.

  1. Click Gradle
  2. Click Signing Report
  3. Copy SHA-1

capture1

  1. went to website & Paste the SHA-1.
    Thanx ! Man !

Thank you very much!

@JosephineAkello
Copy link

I also had the same error, but I found two ways on how to solve it.

  1. Add the key hash in the error message xxxxxxxxx= to the apps key hashes in facebook developers pagehttps://developers.facebook.com/, save then rerun the app.
    or
  2. Find your sha-1 configuration by coping keytool -list -printcert -jarfile YOUR_APK_NAME.apk
    to your your terminal, then convert it to base 64 using http://tomeko.net/online_tools/hex_to_base64.php
    copy the key hash to your facebook developers account hashes, rerun the app and it will work.

@hassan-dev
Copy link

After trying every possible solution (with no luck), downloaded a hash key extractor app : https://apkpure.com/key-hash-key/notimeforunch.keyhash

Copy pasted the hash key using the app and no more invalid hash key errors.

Thanks man, its working!

@hassan-dev
Copy link

This is how i solved this problem

first get you SHA1 from keystore file
keytool -list -v -keystore keystore_file_name.jks -alias key0

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.
This is what Facebook requires
get the generated hash " ********************= " and copy the key hash to the facebook app.

refer the image

awesome

@hafs-r
Copy link

hafs-r commented Oct 7, 2019

Google play sign it if you use app bundle to release, so generate new hash key from signing key SHA 1 from google play store

@bishwajeet-billme
Copy link

This is how i solved this problem

first get you SHA1 from keystore file
keytool -list -v -keystore keystore_file_name.jks -alias key0

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.
This is what Facebook requires
get the generated hash " ********************= " and copy the key hash to the facebook app.

refer the image

superb, this solution is worked.
Thank you.

@KangYoosam
Copy link

#297 (comment)
this solution helped my problem

@birdeveloper
Copy link

After trying every possible solution (with no luck), downloaded a hash key extractor app : https://apkpure.com/key-hash-key/notimeforunch.keyhash

Copy pasted the hash key using the app and no more invalid hash key errors.

Thanks Bro

@ariona
Copy link

ariona commented Feb 4, 2020

Google play sign it if you use app bundle to release, so generate new hash key from signing key SHA 1 from google play store

@hafsalrahman elaborate please on how to to do it? i am facing the problem, the hash didn't match from facebook login error,

@limkokhole
Copy link

limkokhole commented Feb 26, 2020

To get rid of tomeko.net site, you can simply use this shell command to get the same output:

echo -n aa:bb:xx | sed s/://g | xxd -pu -r | base64

@tomoima525
Copy link

@ariona Open PlayStore console -> App signing

Then copy SHA1

Screen Shot 2020-06-30 at 9 46 37 PM

@iamabdulhaseeb
Copy link

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.

The error doesnt show any hash key!

@chahalrohit
Copy link

if this message comes:
invalid key hash. The key hash **************** does not match any stored key hashes.
actually the key hash on screen is the correct key hash,
copy that key hash and paste it into facebook developers app id key hash section
if you use debug app than debug key hash work else if you use release build apk then release key hash work
key hash error

@FetFrumos
Copy link

@madmax124 thank you. It is working. I entered it manually but got one character wrong. just copy.

@jomey-12
Copy link

I generate the key hash from android keystore following Facebook docs:

https://developers.facebook.com/docs/android/getting-started/#release-key-hash

So.. I implemented all of this lib needs to and I received this error message in my emulator:

invalid_key_hash

The problem is that key hash is not my key hash generated and saved in the facebook developers app configurations.

I make a test: put this "new" key hash in facebook developers key hashes too and tried again and I was able to login successfully.

While creating the hash key , the default password is 'android'. If you give any other passwords it wont show an error instead gives you a wrong hash key. That might be your problem.

@elaneri
Copy link

elaneri commented Jun 15, 2021

I just type the hash value into fc console XD

@russcarver
Copy link

Mine has had several lower case L and upper case I. It look forever to figure out, but after zooming in and comparing to their word "Invalid" in the error message, I was able to determine that lower case L are slightly taller than upper case I. The lower case L will go "above" the top of any capital letter. Upper case I will not.

@kcibdev
Copy link

kcibdev commented Nov 9, 2021

Go to your google play console -> Setup -> App Intergrity
You will see a new key generated by google
use that in your facebook and console

@Abdo2021-a
Copy link

thank you so much :# @madmax124

@NyeinAung
Copy link

capital i looks like as small L. Сheck carefully. screenshot_6

thank you so much. this really solved me!

@hieudc110501
Copy link

After trying every possible solution (with no luck), downloaded a hash key extractor app : https://apkpure.com/key-hash-key/notimeforunch.keyhash

Copy pasted the hash key using the app and no more invalid hash key errors.

Thanks bro, I tried many ways but this was a best way. Download "hash key app" and open it to generate a hash key by click your "project" icon in the srcreen. After that copy and paste in your facebook developer app settings.

@kunalnathinfotech
Copy link

I have just solved the issue of the invalid hash key issue

  1. use the following code in terminal keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass anndroid -keypass android to generate the SHA1 key.
  2. use the following website to generate keyhash: http://tomeko.net/online_tools/hex_to_base64.php
  3. store the kehash in your app here: https://developers.facebook.com/apps
  4. Don't forget to delete the keyhash you used which causes the issue.

@HossamBhi
Copy link

My issue was when i uploaded app to google play store there are a two App signing ( one is my release, second may be auto generated by google not my .debug ) in store.
You can find App siging in

Go to Google console => your project => Setup => App Integrity => App signing key certificate.

take your sha1 and convert it to key hash then add to key hashes in facebook app.
You can use this command to generate key hash.
echo {sha1} | xxd -r -p | openssl base64;

@JaySyntax
Copy link

If you are coming from flutter world, what i did was to set behavior to web only

loginBehavior: LoginBehavior.webOnly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests