Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

facebook hash key when using android studio

i am using android studio to develop an app which uses facebook sdk.

when i used the following command

C:\Program Files\Java\jdk1.7.0_21\bin>keytool -exportcert -alias androiddebugkey  -keystore "C:\Users\ninad\.android\debug.keystore" | "D:\OpenSSL\bin\openssl" s ha1 -binary |"D:\OpenSSL\bin\openssl" base64 

it returned y5EquINHD6DvwVJFyJTuUEY3NSU=

when using this hash key facebook shows the error

invalid android_key parameter. the key c33Tm0FL_-kxyaPZq1JBLDh767U does not match any allowed key.

Is the hash key needed for facebook different when using eclipse and android studio? which among these is my correct hash key?

I added both the hash Key to my app in facebook. still the app shows invalid android_key parameter.

like image 959
null pointer Avatar asked Jun 04 '13 11:06

null pointer


People also ask

How do I get the key hash on Facebook?

Go to your Facebook App --> Settings--> Paste Hash key in "key hashes" option -->save changes. Now Test your android app with Facebook Log-in/Share etc.

What is key hash in android?

You will have to enter a password. The password is: android. A code will come up and that code is your key hash.


2 Answers

WHy dont you try this code and check out the hash key you are using. From the facebook docs:

Besides double checking your key hash generation steps, here is another option that ensures you're using the correct key hash. It involves changing code in one of the sample apps to print the signature sent to Facebook.

@Override public void onCreate(Bundle savedInstanceState) {     super.onCreate(savedInstanceState);      // Add code to print out the key hash     try {         PackageInfo info = getPackageManager().getPackageInfo(                 "your.package",                  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) {      } catch (NoSuchAlgorithmException e) {      } } 
like image 124
Tarun Avatar answered Oct 09 '22 02:10

Tarun


Here is the link to create facebook hash key:

public class FacebookHashKeyActivity extends Activity {      @Override     protected void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         setContentView(R.layout.activity_facebook_hash_key);         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) {             e.printStackTrace();         } catch (NoSuchAlgorithmException e) {             e.printStackTrace();         }     } } 

Code taken from here.

like image 25
Vijay Kumar Avatar answered Oct 09 '22 02:10

Vijay Kumar