1

I'm using Android and facebook-connect to have a simple app which posts to the user's wall. The authentication system appears to work fine if the official Facebook app is not installed - it opens a webview, the user logs in and the app works from then on. However, if the user has the official app installed, the authentication code opens a white screen with the blue facebook banner at the top, with a loading popup dialog. This runs for about a second and then it goes straight back to my app. However, no permissions or login screen was ever shown, as is in the examples. Nor did the app ever receive an access token. Does anyone know what is wrong? My login code follows:

public void authFb(){
    if(!facebook.isSessionValid()) {

        facebook.authorize(this, new String[] {"publish_stream", "offline_access"}, new DialogListener() {
            @Override
            public void onComplete(Bundle values) {
                SharedPreferences.Editor editor = mPrefs.edit();
                editor.putString("access_token", facebook.getAccessToken());
                editor.putLong("access_expires", facebook.getAccessExpires());
                editor.commit();
            }

            @Override
            public void onFacebookError(FacebookError error) {}

            @Override
            public void onError(DialogError e) {}

            @Override
            public void onCancel() {}
        });
    }
}

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    facebook.authorizeCallback(requestCode, resultCode, data);
}

The 'facebook' variable is just a Facebook(HASH) object.

Joel Auterson
  • 728
  • 1
  • 7
  • 26
  • You need to find out what is happening in the response. You should add logging statements to all those empty methods to dump out any response. I'd wager something is coming back in onFacebookError(). No idea what exactly though. Log it. – Walt Armour Oct 25 '11 at 00:09
  • FacebookError outputs "invalid_key". I don't understand - does this mean that my hash is incorrect? And if it is, why does it work without the app? – Joel Auterson Oct 25 '11 at 06:40

1 Answers1

1

this happens because the hash key you gave your app in the facebook developers page is incorrect. check this question for the steps how to do it.

** the only difference is that the line to execute in a shell is this: (exportcert is no longer good)

keytool -export -alias androiddebugkey -keystore "C:\locationOfYourDebugKeystoreFile" | openssl sha1 -binary | openssl base64

for me this was: keytool -export -alias androiddebugkey -keystore "C:\Users\Sean.android\debug.keystore" | openssl sha1 -binary | openssl base64

hope this helps... sean

Community
  • 1
  • 1
sean.net
  • 735
  • 8
  • 25