Access Token Removed when posting facebook sdk 4.0

2019-07-20 14:06发布

问题:

By following the facebook sample for login and posting, after I do login and I get name and photo of my profile , when I try to post on wall in the following part..

if (accessToken != null) {
        pendingAction = action;
        if (hasPublishPermission()) 
{ handlePendingAction();

        } else
        {
                          LoginManager.getInstance().logInWithPublishPermissions(this,Arrays.asList(PERMISSION));
            return;
        }
    }

I get ACCESS_TOKEN_REMOVED permissions: [user_friends,public_profile,basic info] Why the permissions are removed if I successfully login. How can we fix it?

回答1:

Here are some general tips to help you debug this:

  • try to update to the latest SDK
  • try on different devices/emulators
  • try uninstalling the app and re-authorize from here

Now for permission specific issues, make sure to always test first with a user who's an Admin/Developer/Tester of an app, since your test will fail with normal user if you app is:

  • not public (still in development mode)
  • public BUT the permission you are testing against is not yet approved by Facebook


回答2:

Please be sure to override in your Activity the onActivityResult method:

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

    super.onActivityResult(requestCode, resultCode, data);

    Session.getActiveSession().onActivityResult(this, requestCode, resultCode, data);

}