1

when I using new Facebook SDK v3.0.2.b sample HelloFacebookSample, I login to Facebook but I get error:

HelloFBSample is misconfigured for Facebook login.

But I have already generate Hash key and add it to Sample App Setting on Facebook Developer site.

Is anybody get the same defect? Or is it a bug of new SDK?

Dat Tran
  • 136
  • 1
  • 10

1 Answers1

1

Sometimes the Key Hash generated using the method given by the Facebook Doc does not always work as advertised. I have faced this problem and so have a few others.

There are a couple of things you can do to sort it out.

First method

Follow the tutorial on this site: http://www.helloandroid.com/tutorials/using-facebook-sdk-android-development-part-1

This is a little time consuming (about 5 odd minutes I expect) but worked when I tried it.

Second Method (And I personally like this one)

  1. Find the Util.java in the Facebook SDK and open it.
  2. Among the first few lines of code, you should see this piece: private static boolean ENABLE_LOG = false;.
  3. Change the false to true and run your application with your logcat (DDMD) open.
  4. You should see an error that looks something like this:

Login failed: invalid_key:Android key mismatch. Your key "**real*key***" does not match the allowed keys specified in your application settings.

If this is for a testing APK, using the debug.keystore, this will be enough. However, if this is for an app signed with your release key, then follow the steps till Step No. 3 but instead of pushing the app from eclipse, create a signed APK and install that on your device. Don't forget to keep it connected with DDMS running.

This part here: "**real*key***" is your actual key.

Siddharth Lele
  • 27,623
  • 15
  • 98
  • 151
  • 1
    Thank bro for your feedback. Finally I have re-generate the Hash Key and the App run OK. It's maybe the error from keytool ^^ – Dat Tran Nov 30 '12 at 17:29
  • I obtained the correct key from the **First Method**. For the **Second Method**, the key (between the double quotes in the message of `com.facebook.FacebookAuthorizationException`) is missing an _equal sign_ at the end. Since it is [base64](http://en.wikipedia.org/wiki/Base64#Padding), it should end with 0, 1, or 2 _equal signs_. I am using Windows, `facebook-android-sdk-3.0`, `keytool` is `C:\Program Files\Java\jdk1.7.0_02\bin\keytool.exe`, `openssl` is downloaded from [here](http://code.google.com/p/openssl-for-windows/) (from [this answer](http://stackoverflow.com/a/4348379/1402846)). – Pang Dec 26 '12 at 05:16