I\'m building an app in which users can log in with Facebook.
I\'ve created the hash keys like following:
try {
PackageInfo info = getPackag
For future reference, if you already have your app on Play Store you can this:
Go to Release Management
select App Signing
in Release Management
You can see SHA1 key in hex format App signing certificate
.
Copy the SHA1 in hex format and convert it in to base64 format, you can use this link http://tomeko.net/online_tools/hex_to_base64.php to do that without the SHA1:
part of the hex.
Go to Facebook developer console and add the key(after convert to base 64) in the settings —> basic –> key hashes
.
First open the command prompt (Windows + R)
cd C:\Program Files\Java\jre1.8.0_172\bin
Download openssl from HERE
Create a folder named OpenSSL in C:/ drive
Export the downloaded zip file in OpenSSL folder
Generate the command as:-
keytool -exportcert -alias YOUR_ALIAS -keystore "YOUR_KEYSTORE_PATH" | "C:\OpenSSL\bin\openssl" sha1 -binary | "C:\OpenSSL\bin\openssl" base64
Paste the command in command prompt and press enter
Enter password
Here you can see the key :- "1skdhyjsgd56whdjddV+vCLE="
You followed the steps that facebook provides for the creation of a login application?
You need a 'Production keyhash' obtained starting your release keystore:
From comand line:
keytool -exportcert -alias <RELEASE_KEY_ALIAS> -keystore <RELEASE_KEY_PATH> | openssl sha1 -binary | openssl base64
And add this key on facebook app page options.
More information: https://developers.facebook.com/docs/android/getting-started/
// add this method to your first activity and open log and search for Base64 tag this is the Hashkey i hoop it help
public void getHashkey(){
try {
PackageInfo info = getPackageManager().getPackageInfo(getApplicationContext().getPackageName(), PackageManager.GET_SIGNATURES);
for (Signature signature : info.signatures) {
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
Log.i("Base64", Base64.encodeToString(md.digest(),Base64.NO_WRAP));
}
} catch (PackageManager.NameNotFoundException e) {
Log.d("Name not found", e.getMessage(), e);
} catch (NoSuchAlgorithmException e) {
Log.d("Error", e.getMessage(), e);
}
}
Facebook SDK uses two different keys, one is Debug key which you can use during your development phase and other is Release key which is used once you create a signed application package. Here is a link about how to create debug and release keys.
Developer.Facebook
Also check out this SO post.
The simplest solution.
1) Sign your Apk.
2) Connect your device to machine and Install signed apk on real device.
3) When facebook login is pressed, you will get an error saying "Invalid key hash. The key hash "xxx" does not match any stored key. ..." on your logcat.
4)Copy the logcat Hash Key and put this key to developers.facebook.com/apps/104...../settings/