Skip to content
This repository has been archived by the owner on Apr 2, 2021. It is now read-only.

The Key Hash Does not match any store key hashes. #424

Closed
i-suraj opened this issue Nov 24, 2018 · 33 comments
Closed

The Key Hash Does not match any store key hashes. #424

i-suraj opened this issue Nov 24, 2018 · 33 comments

Comments

@i-suraj
Copy link

i-suraj commented Nov 24, 2018

screenshot_20181124-144834
I tried to generate hash by using
>keytool -exportcert -alias payoja -keystore "C:\Users\Epsum Labs\Desktop\PAYOJA\android\app\payoja.keystore" | "C:\Users\Epsum Labs\Desktop\openssl\bin\openssl" sha1 -binary | "C:\Users\Epsum Labs\Desktop\openssl\bin\openssl" base64

I am unable to login neither in debug nor in release mode.

@humarkx
Copy link

humarkx commented Nov 24, 2018

I have the same problem, without the app installed, it works, when the facebook app is installed, I get the invalid key hash, however, the hash that gives on the error, is on facebook app.

Help plz

@sergiulucaci
Copy link

Make sure you get the hash of the signed key used for generated APK.

MacOS:

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

Real example, assuming that keystore is placed under android/app:

keytool -exportcert -alias my-key-alias -keystore android/app/my-release-key.keystore | openssl sha1 -binary | openssl base64

This will generate a hash key that must be placed into app's profile:

  1. Go to https://developers.facebook.com/apps/YOUR_APP_ID/settings/basic/
  2. Scroll down to Android Key Hashes
  3. Place the key there

Source

@i-suraj
Copy link
Author

i-suraj commented Dec 6, 2018

any solution for this???

@drpshtiwan
Copy link

Here is the same, anyone has any solution??

@duarte-evocorp
Copy link

I have the same problem

@CapitanRedBeard
Copy link

For me it was redirecting to the FB app and it was displaying a hash that I never generated. I copied that hash into the FB console and it seemed to work after that. Not quite sure why.

@Ovi
Copy link

Ovi commented Mar 3, 2019

This worked for me.

Copy the APK to your PC in Program Files\java\jdkX.X.X_XXX\bin folder

In my case it's C:\Program Files\Java\jdk1.8.0_191\bin

Open CMD in this directory and type the following

keytool -list -printcert -jarfile YOUR_APK_NAME.apk

Copy the SHA1 value to your clipboard It will be something like this: 79:D0:E6:80:4E:28:1E:D1:88:28:CB:D7:E6:BE:2E:0C:FB:24:98:52

Then go to 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 your Facebook developers app settings.

@nuclearWinters
Copy link

nuclearWinters commented Mar 11, 2019

I used the openssl version "openssl-0.9.8e_X64.zip" in windows, the others generate false hashes

@masierraf
Copy link

Anyone has any solution?

@ramanaptr
Copy link

ramanaptr commented Mar 31, 2019

  • I've been solved this issue using java/kotlin code here

Kotlin:

    fun createKeyHash(activity: Activity, yourPackage: String) {
        val info = activity.packageManager.getPackageInfo(yourPackage, PackageManager.GET_SIGNATURES)
        for (signature in info.signatures) {
            val md = MessageDigest.getInstance("SHA")
            md.update(signature.toByteArray())
            Log.d("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT))
        }
    }

Java:

    public static void createKeyHash(Activity activity, String yourPackage) {
        try {
            PackageInfo info = activity.getPackageManager().getPackageInfo(yourPackage, 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) {
            e.printStackTrace();
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        }
    }

and call your function like this

createKeyHash(this, "com.ramana.myapp")

Note: "com.ramana.myapp" it is my package path/name and to see your keyhash please type search the debug on logcat with message 'KeyHash'.
Base64 must be import android.util.Base64 dont import java.util.
*

@UzairAhmedSiddiqui
Copy link

Solved this for myself, I carefully added the correct hash of my release key but my app keep complaining about key hash does not match any store key hashes and showed a hash which was different from my release key hash.
After going nuts over where this new hash comes from I finally figured out that google play probably also signs the apk when you upload it. so after publishing if you go to google play console you will see find versions of the apk, one signed by your release key and another derived apk probably signed by google.

You have to download the derived apk and get the SHA1 hash using
keytool -list -printcert -jarfile YOUR_APK.apk
the output will be in Hex so you'll have to convert it into base64, and it will be the same hash that the app complains about after being published to store.

I don't know why this isn't mentioned in facebook dev console and their docs.

@tuononh
Copy link

tuononh commented May 20, 2019

Check if your "App Signing by Google Play" is enabled. Then copy SHA1 from there and go to http://tomeko.net/online_tools/hex_to_base64.php to get the key hash.

@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

@Seerat-Ahmed
Copy link

Solved this for myself, I carefully added the correct hash of my release key but my app keep complaining about key hash does not match any store key hashes and showed a hash which was different from my release key hash.
After going nuts over where this new hash comes from I finally figured out that google play probably also signs the apk when you upload it. so after publishing if you go to google play console you will see find versions of the apk, one signed by your release key and another derived apk probably signed by google.

You have to download the derived apk and get the SHA1 hash using
keytool -list -printcert -jarfile YOUR_APK.apk
the output will be in Hex so you'll have to convert it into base64, and it will be the same hash that the app complains about after being published to store.

I don't know why this isn't mentioned in facebook dev console and their docs.

This solved my problem :)

@MayarAhmed
Copy link

@UzairAhmedSiddiqui unfortunately i followed these steps but didn't work with me

Did you figure any other solution??

@UzairAhmedSiddiqui
Copy link

@UzairAhmedSiddiqui unfortunately i followed these steps but didn't work with me

Did you figure any other solution??

@MayarAhmed I'm afraid not, but if the error is the same then it should work, the problem simply is that the hash of the signed apk and the one set on facebook dev console do not match.
If you're also signing the apk yourself then you can try disabling app signing by google play and use the hash of your own certificate.

@i-suraj i-suraj closed this as completed Aug 14, 2019
@MayarAhmed
Copy link

MayarAhmed commented Aug 19, 2019

this step solved it for me

Copy the File debug.keystore from .android folder in my case (C:\Users\SYSTEM.android) and paste into JDK bin Folder in my case (C:\Program Files\Java\jdk1.6.0_05\bin)

and then excute cmd

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

which gives me the same hash code in the error and then it solved

@BDominik
Copy link

This worked for me.

Copy the APK to your PC in Program Files\java\jdkX.X.X_XXX\bin folder

In my case it's C:\Program Files\Java\jdk1.8.0_191\bin

Open CMD in this directory and type the following

keytool -list -printcert -jarfile YOUR_APK_NAME.apk

Copy the SHA1 value to your clipboard It will be something like this: 79:D0:E6:80:4E:28:1E:D1:88:28:CB:D7:E6:BE:2E:0C:FB:24:98:52

Then go to 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 your Facebook developers app settings.

Thank you this is helped me.

@milkmanjr
Copy link

milkmanjr commented Nov 7, 2019

This fixed it for me

expo/expo#2079

Specifically expo/expo#2079 (comment)

@nguyen95
Copy link

nguyen95 commented Dec 13, 2019

We can get hash from Android studio: CLick Gradle --> double clicks signingReport --> get SHA1 --> convert to hash
image

@ChinGyi2019
Copy link

#424 (comment)
here is the answer above Explain!! thanks

@amitbravo
Copy link

This worked for me.

Copy the APK to your PC in Program Files\java\jdkX.X.X_XXX\bin folder

In my case it's C:\Program Files\Java\jdk1.8.0_191\bin

Open CMD in this directory and type the following

keytool -list -printcert -jarfile YOUR_APK_NAME.apk

Copy the SHA1 value to your clipboard It will be something like this: 79:D0:E6:80:4E:28:1E:D1:88:28:CB:D7:E6:BE:2E:0C:FB:24:98:52

Then go to 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 your Facebook developers app settings.

what possible location can be for OSX ?

@kenpham4real
Copy link

This worked for me.

Copy the APK to your PC in Program Files\java\jdkX.X.X_XXX\bin folder

In my case it's C:\Program Files\Java\jdk1.8.0_191\bin

Open CMD in this directory and type the following

keytool -list -printcert -jarfile YOUR_APK_NAME.apk

Copy the SHA1 value to your clipboard It will be something like this: 79:D0:E6:80:4E:28:1E:D1:88:28:CB:D7:E6:BE:2E:0C:FB:24:98:52

Then go to 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 your Facebook developers app settings.

I met the same issue while I did generate a SHA1 key before. I solved it now thanks to the link you provide. Thank you very much !

@trOnk12
Copy link

trOnk12 commented Apr 26, 2020

Somehow when I am running it in windows powershell the generated code has the wrong format but when I run it in cmd the format is valid, hopefully it helps someone.

@ghasemikasra39
Copy link

any solution ?

@Hansel03
Copy link

We can get hash from Android studio: CLick Gradle --> double clicks signingReport --> get SHA1 --> convert to hash
image

This worked for me.

Copy the SHA1 value to your clipboard It will be something like this: 79:D0:E6:80:4E:28:1E:D1:88:28:CB:D7:E6:BE:2E:0C:FB:24:98:52

Then go to 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 your Facebook developers app settings.

@PirunSeng
Copy link

PirunSeng commented May 18, 2020

Hi there, same issue here. But first, I wonder why the complaint invalid key hash is different from the one I have. And second, where I can get the apk file? During development, is it required that we need to register the app with Google Play?
PS: I am using Windows OS.

@SaravananRath
Copy link

SaravananRath commented May 18, 2020

This worked for me.

Copy the APK to your PC in Program Files\java\jdkX.X.X_XXX\bin folder

In my case it's C:\Program Files\Java\jdk1.8.0_191\bin

Open CMD in this directory and type the following

keytool -list -printcert -jarfile YOUR_APK_NAME.apk

Copy the SHA1 value to your clipboard It will be something like this: 79:D0:E6:80:4E:28:1E:D1:88:28:CB:D7:E6:BE:2E:0C:FB:24:98:52

Then go to 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 your Facebook developers app settings.

Use the above method to generate the key.(Just create a debug apk and run the command pointing to it.)
After spending couple of hours on this. I found out.
No point of adding keyhash here(as per documentation) - https://developers.facebook.com/settings/developer/sample-app/

Add the Key Hash Here - https://developers.facebook.com/docs/facebook-login/android/v2.2

  1. Select your app name
  2. Add keyhash in step 6.

@PirunSeng
Copy link

Hi there, same issue here. But first, I wonder why the complaint invalid key hash is different from the one I have. And second, where I can get the apk file? During development, is it required that we need to register the app with Google Play?
PS: I am using Windows OS.

Just solved my issue by pointing to debug keystore in the project itself "PATH_TO_YOUR_PROJECT/android/app/debug.keystore"

@brianasu-notdoppler
Copy link

If you use Google's new android upload key method then your apk gets re-signed after it uploads. The keystore you use to upload is not the actual keystore google signs it with.

You have to go into your Google play release page and download the resigned apk before doing the above steps by OVI. They called it derived APK.

@parnekov
Copy link

We can get hash from Android studio: CLick Gradle --> double clicks signingReport --> get SHA1 --> convert to hash
image

This worked for me.
Copy the SHA1 value to your clipboard It will be something like this: 79:D0:E6:80:4E:28:1E:D1:88:28:CB:D7:E6:BE:2E:0C:FB:24:98:52
Then go to 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 your Facebook developers app settings.

This works on Mac. Thank you!!!

@Blossom-Solutions
Copy link

Hi there, same issue here. But first, I wonder why the complaint invalid key hash is different from the one I have. And second, where I can get the apk file? During development, is it required that we need to register the app with Google Play?
PS: I am using Windows OS.

Just solved my issue by pointing to debug keystore in the project itself "PATH_TO_YOUR_PROJECT/android/app/debug.keystore"

You are a saviour mate, this worked for me. Kudos!

@d0uguit0s
Copy link

Olá, mesmo problema aqui. Mas primeiro, eu me pergunto por que o hash da chave inválida da reclamação é diferente do que eu tenho. E em segundo lugar, onde posso obter o arquivo apk? Durante o desenvolvimento, é necessário registrar o aplicativo no Google Play?
PS: Estou usando o sistema operacional Windows.

Acabei de resolver meu problema apontando para debug keystore no próprio projeto "PATH_TO_YOUR_PROJECT / android / app / debug.keystore"

eu quero te agradecer mil milhões <3

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

No branches or pull requests