Tuesday, May 13, 2014

Invalid android_key parameter - Facebook login

Have you ever seen this error message?

Invalid android_key parameter - Facebook login


To fix this issue add this code to onCreate of your activity
You can find your Hash Key in eclipse - LogCat -  tag "====Hash Key==="
Copy and paste key hash to your app on developers.facebook.com

try {

PackageInfo info = getPackageManager().getPackageInfo(
this.getPackageName(), PackageManager.GET_SIGNATURES);

for (Signature signature : info.signatures) {

MessageDigest md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
Log.d("====Hash Key===",
Base64.encodeToString(md.digest(), Base64.DEFAULT));

}

} catch (NameNotFoundException e) {

e.printStackTrace();

} catch (NoSuchAlgorithmException ex) {

ex.printStackTrace();

}


Attention: When running unsigned version you will get the wrong hash key. The version must be signed. Then you can find your key when filtering by tag name: "KeyHash:"

No comments:

Post a Comment