1
votes

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.

  1. Add the build hint android.facebook_permissions key with value the permissions you want. This is a must step. Only include read permission here and not the publish_action permission or other write permissions. If you need no permission other than write permission add public_profile which is the default permission of facebook.
  2. Use FacebookConenct.askPublishPermissions for the publish_actions permission.
  3. If you use doLogin() first then for some reason askPublishPermission did nothing in my case. So i used askPublishPermission without calling doLogin() which automatically called the login page.
1

1 Answers

0
votes

How did you request permissions?

Did you notice that you need to call askPublishPermissions to write?

Unlike a web application a native application needs to ask for write permissions.

Did you set the build hint android.facebook_permissions as explained here?