Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"An error's occurred" when authenticating with Facebook's android sdk

I'm authenticating user's (or trying to) with my android app that I've been working on and all I get from the facebook dialog is that an error has occurred with no details as to what the error is. There are not exceptions being thrown for me to chase or anything of the sort. I've followed http://developers.facebook.com/docs/guides/mobile/#android to create my login dialog.

The page says use new Facebook("YOUR_APP_ID"); which results in the error, I've also tried the api key but it gives the same thing. I'm not doing anything else except toasting but I don't even get a response in the callback until I hit the return key to leave the facebook dialog

public class Base {
private Facebook fb;

    public Base() {
        fb = new Facebook("app_id_here");
    }

    public void onCreate(Bundle b) {
        super.onCreate(b);
    }

    private void doLogin() {
        fb.authorize(this, new DialogListener() {
            public void onComplete(Bundle values) {
                Toast.makeText(getApplicationContext(), values.toString(),
                        Toast.LENGTH_LONG).show();
            }
            public void onFacebookError(FacebookError error) {
                Toast.makeText(getApplicationContext(), error.getMessage(),
                        Toast.LENGTH_LONG).show();

            }

            public void onError(DialogError e) {
                Toast.makeText(getApplicationContext(), e.getMessage(),
                        Toast.LENGTH_LONG).show();
            }

            public void onCancel() {
                Toast.makeText(getApplicationContext(),
                        "You must be registered and signed in to perform that action",
                        Toast.LENGTH_LONG).show();

            }
        });
    }

    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        fb.authorizeCallback(requestCode, resultCode, data);
    }
}

Any idea why this will be giving an error or where/how I can find what's causing the error P.S I've also added the key hash under "Mobile and Devices" on the FB app settings page and this isn't the same problem as found over at Login failed invalid key error with Facebook SDK I've tried the suggestions over there. It doesn't work

like image 522
zcourts Avatar asked Dec 06 '22 21:12

zcourts


1 Answers

I also faced this problem. First of all I need to know which Key Hash value you entered on facebook app if it is 'ga0RGNYHvNM5d0SLGQfpQWAPGJ8=' then that is the problem. I think you entered

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

this one on the terminal and you entered your own password to generate the key hash. if you done that please try do the following things also you enter the above command on terminal(I am using UBUNTU(linux). You type the command corresponding to which OS you are using) and enter the password as 'android'. This time you will get a different hey hash value. Copy that value and save it as the key hash value for your facebook app. After that check it is working or not. For me it worked. This will occur when we are using the debug key. After all this when you are about to publish this application on the Android market you will have to again change the key hash value according to the private key you are using. Try this may be this will help you.

like image 161
Basil Avatar answered Jan 03 '23 21:01

Basil