Question

I was trying to get the key hash from my Android app. Facebook SDK 3.0 gave the following code:

keytool -exportcert -alias androiddebugkey -keystore %HOMEPATH%\.android\debug.keystore | openssl sha1 -binary | openssl base64

When I run this it first says binary:no error; It then asks for the password which I enter as android. Upon pressing enter it returns blank where I expect the pass code.

I used the solution mentioned here; this did give me a key hash but when I use that none of the sessions are opening.

My java keytool is stored in :

C:\Program Files\Java\jre7\bin

And OpenSSL is stored in :

F:\openssl\bin

I am giving the correct file paths when I run it in MD in Windows.

Kindly help me figure this out!

Was it helpful?

Solution

You might got the password wrong.

Look at my answer Here.

Hope that helps

OTHER TIPS

Windows is always a little hairy and tricky to get the keytool, I suggest the alternative. Run the following code in the onCreate method of your app:

   try {
        PackageInfo info = getPackageManager().getPackageInfo(
            "COM.YOUR.PACKAGE.NAME", 
            PackageManager.GET_SIGNATURES);
        for (Signature signature : info.signatures) {
            MessageDigest md = MessageDigest.getInstance("SHA");
            md.update(signature.toByteArray());
            Log.d("My Keyhash", Base64.encodeToString(md.digest(), Base64.DEFAULT));
        }
    } catch (Exception e) {
        Log.e("My Keyhash", e.toString());
    } 

and observe the log output in logcat to obtain your keyhash. Make sure to replace the package name above with your own.

EDIT:

the key hash is correctly uploaded but the session still does not open... while logging on to facebook it first requests for my permission throgh the app and the after i accept a popup come up saying "com.facebook.facebookexception: Session Provided to a request in unopened state"

Make sure you have this code in your Fragment/Activity:

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    uiHelper.onActivityResult(requestCode, resultCode, data);
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top