I am trying to post on the facebook wall of the user using FacebookConnect but the method createOauth2() method is overriding the scope by the its own permissions.
EDIT
if (fb.isNativeLoginSupported()) { Dialog.show("native", "Yes", "Ok", null); if (!fb.hasPublishPermissions()) { Dialog.show("permission", " no publish permission", "ok", null); fb.askPublishPermissions(new LoginCallback() { @Override public void loginSuccessful() { Dialog.show("permission", "accessed: " + fb.hasPublishPermissions(), "Ok", null); System.out.println("permission: " + fb.hasPublishPermissions()); token = fb.getAccessToken().getToken(); PhotoShare share = new PhotoShare(); share.sendPhoto(token, id); } @Override public void loginFailed(String errorMessage) { System.out.println("failed permission: " + errorMessage); Dialog.show("permission error", errorMessage, "Ok", null); } }); } else { Dialog.show("permission", "publish permission", "ok", null); PhotoShare share = new PhotoShare(); share.sendPhoto(token, id); } } else { Dialog.show("permission", "No native support", "Ok", null); fb.setScope("publish_actions"); fb.setCallback(new LoginCallback() { @Override public void loginSuccessful() { token = fb.getAccessToken().getToken(); PhotoShare share = new PhotoShare (); share.sendPhoto(token, id); } }); fb.doLogin(); }
The Logincall back of askPublishPermissions never gets called on the android device.
Also when login the app ask for permissions of friendlist and email which I never asked. In the source code of FacebookConnect the createOuth() method is adding them in scope but I dont need those permissions.
Solution:
These are the steps I followed for anyone with same problem. First I found problem with the emulator asking permission. So I created my own Outh login asking the permission.
For the android build.
- Add the build hint
android.facebook_permissionskey with value the permissions you want. This is a must step. Only include read permission here and not thepublish_actionpermission or other write permissions. If you need no permission other than write permission addpublic_profilewhich is the default permission of facebook. - Use
FacebookConenct.askPublishPermissionsfor thepublish_actionspermission. - If you use
doLogin()first then for some reasonaskPublishPermissiondid nothing in my case. So i usedaskPublishPermissionwithout callingdoLogin()which automatically called the login page.