Question

I have an issue with SSO using the Facebook SDK for Android. The problem occurs only when the native Facebook application is installed. When it's not installed, everything works fine, specifically:

Facebook facebook = new Facebook(APP_ID);
facebook.authorize(mActivity, , new DialogListener() {
   ...
});

facebook.isSessionValid(); // returns true

But when the native application is installed, facebook.isSessionValid() still returns false despite the fact that I called the authorize method.

I should add that I created an native Android based Facebook application with the hashkey generated from my debug certificate using keytool.

keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64

What is going on?

Was it helpful?

Solution

SOLVED! :)

I sure hope this will work for you as well. The problem is that Windows generates an invalid key.

Run this with your app:

try {
   PackageInfo info = getPackageManager().getPackageInfo("**YOURPACKAGENAME**", PackageManager.GET_SIGNATURES);
   for (Signature signature : info.signatures) {
        MessageDigest md = MessageDigest.getInstance("SHA");
        md.update(signature.toByteArray());
        Log.i("PXR", Base64.encodeBytes(md.digest()));
   }
}
catch (NameNotFoundException e) {}
catch (NoSuchAlgorithmException e) {}

Don't forget to get Base64 (http://iharder.sourceforge.net/current/java/base64/).

The generated key is on your logcat, replace the old one with this.

Solution thanks to: http://p-xr.com/implementing-facebook-into-your-app-invalid-key-with-keytool/

OTHER TIPS

In addition to what Lior wrote

you can do the log like this:

Log.d("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT));

so you can use Andorid Base64

ref: Invalid Key Hash Troubleshooting

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top