Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook SDK : ApiException:The proxied app cannot request publish permissions without having being installed previously

I am struggling with the Android facebook SDK 3.5 riigth ow. Everything works perfect with my accounts. Now I gave the App to a friend of mine and when he loggs in he does notget glogged in because of this failure:

ApiException:The proxied app cannot request publish permissions without having being installed previously

11-19 12:18:43.530: W/System.err(13495): com.facebook.FacebookAuthorizationException: UnknownError: 

ApiException:The proxied app cannot request publish permissions without having being installed previously.
11-19 12:18:43.530: W/System.err(13495):    at com.facebook.Session.handleAuthorizationResult(Session.java:1078)
11-19 12:18:43.530: W/System.err(13495):    at com.facebook.Session.onActivityResult(Session.java:554)
11-19 12:18:43.530: W/System.err(13495):    at com.lochmann.viergewinntmultiplayerfb.MainActivity.onActivityResult(MainActivity.java:289)
11-19 12:18:43.530: W/System.err(13495):    at android.app.Activity.dispatchActivityResult(Activity.java:5390)
11-19 12:18:43.530: W/System.err(13495):    at android.app.ActivityThread.deliverResults(ActivityThread.java:3178)
11-19 12:18:43.530: W/System.err(13495):    at android.app.ActivityThread.handleSendResult(ActivityThread.java:3225)
11-19 12:18:43.535: W/System.err(13495):    at android.app.ActivityThread.access$1100(ActivityThread.java:140)
11-19 12:18:43.535: W/System.err(13495):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1275)
11-19 12:18:43.535: W/System.err(13495):    at android.os.Handler.dispatchMessage(Handler.java:99)
11-19 12:18:43.535: W/System.err(13495):    at android.os.Looper.loop(Looper.java:137)
11-19 12:18:43.535: W/System.err(13495):    at android.app.ActivityThread.main(ActivityThread.java:4898)
11-19 12:18:43.535: W/System.err(13495):    at java.lang.reflect.Method.invokeNative(Native Method)
11-19 12:18:43.535: W/System.err(13495):    at java.lang.reflect.Method.invoke(Method.java:511)
11-19 12:18:43.535: W/System.err(13495):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
11-19 12:18:43.535: W/System.err(13495):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
11-19 12:18:43.540: W/System.err(13495):    at dalvik.system.NativeStart.main(Native Method)

Here is my login Code

public void login(final Activity activity, final IFBCallbacks callback) {
        if (isLoggedin()) {
            if (callback != null)
                callback.onLoggedIn();

            actionsAfterLoggedIn(activity, callback);
            Log.i(TAG, "Already Logged in");
            return;
        }
        if (!isLoggedin()) {
            Log.i(TAG, "login() NOT LOGGED IN");
            logout(activity, null);
        }
        Log.i(TAG, "NOT LOGGED IN");
        _session = new Session.Builder(activity).build();
        Session.setActiveSession(_session);
        Session.OpenRequest request = new Session.OpenRequest(activity);
        // Note that you cannot set email AND publish_actions in the same
        // request
        request.setPermissions(getNeededPermisiions());
        // request.setLoginBehavior(SessionLoginBehavior.SUPPRESS_SSO);
        StatusCallback scallback = new StatusCallback() {

            @Override
            public void call(Session session, SessionState state,
                    Exception exception) {
                if (state.isOpened() && hasPermissions(getNeededPermisiions())) {
                    Log.i(TAG, "Succesfully logged in to facebook");
                    if (callback != null)
                        callback.onLoggedIn();

                    actionsAfterLoggedIn(activity, callback);
                    session.getAccessToken();
                    FBUtils.saveAccesToken(activity, session.getAccessToken(),
                            session.getExpirationDate());
                    return;
                }

                // Grant permissions
                if (!session.getPermissions().containsAll(
                        getNeededPermisiions())
                        && session.isOpened()) {
                    Log.i(TAG, "Not all needed Permissions granted");
                    // session.requestNewPublishPermissions(new
                    // Session.NewPermissionsRequest(
                    // activity, getNeededPermisiions()));
                    return;
                }

                // EVERYTHING ELSE
                if (!state.isOpened() && exception != null) {
                    Log.e(TAG, "Unable to login in");
                    exception.printStackTrace();
                    if (callback != null)
                        callback.onError(exception);
                }
            }
        };

        _session.addCallback(scallback);
        _session.openForPublish(request);
    }

I think i need the Install request but I can not find any solution how to fix it. Could anybody give me a few hint?

like image 583
A.S. Avatar asked Nov 19 '13 11:11

A.S.


1 Answers

You need to separate "read" and "publish" permissions, and before you can request a publish permission, you need to get at least "basic_info" first, which is a read permission.

If you're ONLY doing a openForPublish without having any read permissions, then you will get this error.

like image 52
Ming Li Avatar answered Oct 17 '22 10:10

Ming Li