Question

We are using

Permission[] permissions = new Permission[] {
        Permission.PUBLIC_PROFILE,
        Permission.EMAIL,
        Permission.USER_FRIENDS,
        Permission.PUBLISH_ACTION
    };
SimpleFacebookConfiguration configuration = new SimpleFacebookConfiguration.Builder()
        .setAppId(getResources().getString(R.string.app_id))
        .setNamespace("ournamespace")
        .setPermissions(permissions)
        .build();

        SimpleFacebook.setConfiguration(configuration);   

In the login activity:

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

@Override
public void onResume() {
    super.onResume();
    mSimpleFacebook = SimpleFacebook.getInstance(this);     
}
@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login);

    ctx = this;

    ImageView fbBtn = (ImageView) findViewById(R.id.authButton);
    fbBtn.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            mSimpleFacebook.login(onLoginListener);
        }
    });
}   

However, the access token that is generated doesnt include the publish_actions permission... what is wrong here?

Thanks!

Was it helpful?

Solution

In one of the recent changes of this library, added new option to SimpleFacebookConfiguration. It is called setAskForAllPermissionsAtOnce. If the value is true then it asks for all permissions at once and you will have the PUBLISH permissions in the accessToken if user accept it on login.

If it is false then it behaves in different way. Only when user makes his first PUBLISH action, only then the dialog with permissions will be shown for the first time. The default value is false since this complies better to Facebook policy. But you can change it. Check all options here: https://github.com/sromku/android-simple-facebook#configuration-options

You can also use SimpleFacebook.requestNewPermissions() method to ask for permissions again or for new one in the middle of your app flow, when you decide it is good to ask from user.

OTHER TIPS

You app need to be reviewed by FaceBook people if you need publish_actions permission.

Review is not required if you only need public profile, Email, App friends permission.

And I guess to generate AccessToken based on publish_actions permission, your app need to be reviewed.

See the facebook developer link,

https://developers.facebook.com/docs/facebook-login/permissions/v2.0

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top