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
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.
After hours of trying I've finally found a solution.
- Delete any app on the website of Facebook (developers.facebook.com)
- Delete the file debug.keystore under
C:\Users\yourUserName\.android
- Generate a new key (by running your app again)
- Create a new app on developers.facebook.com and add the new hash key
- Re-run your app
- Succes!
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.
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.
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
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.
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
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
- Check your Key hash value.
- Uninstall the Facebook application from your phone.
- Then try again using SDK.
This solved my problem.
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 :
- Go to your private facebook account which you try to log in
- Then click More in app dir
- Click Settings
And then click cross
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 ...
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();
}
}
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
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.
"Enabled Single Sign On for Your App" that's why it work only one time. please go to developer.facebook and check settings.it work for me
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.
You are may be using wrong password the default password for debug keystore is 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:
- Go to Google Play Console
- Click Release Management
- Click App Signing
- Convert App-Signing Certificate SHA-1 to Base64 (this will be different than your current upload certificate)
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.
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 :
- Get your sha1 using this tool :
keytool -exportcert -keystore path-to-debug-or-production-keystore -list -v
- 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
This is how i solved this problem
- 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.
来源:https://stackoverflow.com/questions/20301025/facebook-key-hash-does-not-match-any-stored-key-hashes