xxxApp is misconfigured for Facebook login.Press Okay to go back to the application without connecting to Facebook.
点击Okay后回调我们的应用时,会返回这样的错误信息:
com.facebook.android.FacebookError: invalid_key: Android key mismatch. Your key "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx" does not match the allowed keys specified in your application settings. Check your application settings at http://www.facebook.com/developers
补充一下:
两种方式可以获取到debug的 hash key
1.
keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64
2.
// Add code to print out the key hash
try {
PackageInfo info = getPackageManager().getPackageInfo(
"com.facebook.samples.hellofacebook",
PackageManager.GET_SIGNATURES);
for (android.content.pm.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) {
}
需要注意一点的是,生成keystore时,如果有-alias xxx参数,如:keytool -genkey -v -keystore mykeystore.keystore -alias mykeystore -keyalg RSA -keysize 2048 -validity 10000
那么在生成hash key时 就要加该参数,否则不能加,要对应好。虽然加了也不会报错,也能生成hash key 但是这个key是不对的,无法通过facebook的验证。