Home » Android » Android Facebook.authorize don't call oncomplete method

Android Facebook.authorize don't call oncomplete method

Posted by: admin June 15, 2020 Leave a comment


I’m trying to integrate facebook login on my android app. I found a lot of examples on internet, but now I have the following problem and I can’t find a solution.

After facebook.authorize finish work, the oncomplete method is never called.
If I use the facebook.authorize with Facebook.FORCE_DIALOG_AUTH, in this case the oncomplete method is called and I can save the access_token.
I attach a snipped of my code.
Can anyone help me to solve this problem?

  if(!facebook.isSessionValid()) {         
 facebook.authorize(Login.this, new String[] {"publish_stream","read_stream", "offline_access"}, //Facebook.FORCE_DIALOG_AUTH, 
        new DialogListener() {

                public void onComplete(Bundle values) {

                        SharedPreferences.Editor editor = mPrefs.edit();
                        editor.putString("access_token", facebook.getAccessToken());
                        editor.putLong("access_expires", facebook.getAccessExpires());

                public void onFacebookError(FacebookError error) {Log.e("FB:","Facebook Error" );}

                public void onError(DialogError e) {Log.e("FB:","Error" );}

                public void onCancel() {}


How to&Answers:

Make sure that you implemented onActivityResult() properly as stated in the official documentation:

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

    facebook.authorizeCallback(requestCode, resultCode, data);