2

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!

Himberjack
  • 5,682
  • 18
  • 71
  • 115
  • You should not ask for publish permissions when the user login. You should ask for it when you need it. You also need to get it approved if you want to ask people that doesn't have a role on the app for it – WizKid Jun 03 '14 at 06:30
  • Apart from the above, You should not mix read and write permissions. – Skynet Jun 03 '14 at 06:32

2 Answers2

2

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.

sromku
  • 4,663
  • 1
  • 36
  • 37
0

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

Spring Breaker
  • 8,233
  • 3
  • 36
  • 60