Posts Tagged ‘hashkey’

Hello Droids,

As we get error in applying Facebook SSO (Single Sign On ) feature in app, stating that,

“your application is miss-configured..” the problem is in generating the Hash key.

So lets generate the hash key from the application not from the console and use that hash key in Facebook app, which will configure your app with Facebook SSO 🙂

here is the code for that,

/** 
* Add this code to print out the key hash, and use that KeyHash
* 
*/
 try {
      PackageInfo info = getPackageManager().getPackageInfo(
      "com.myapp", 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) {

}