6

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?

Janusz
  • 187,060
  • 113
  • 301
  • 369
A.S.
  • 4,574
  • 3
  • 26
  • 43
  • 1
    What are all the permissions you're requesting? 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. – Ming Li Nov 19 '13 at 18:23
  • Thanks man, did figure it out 1 hour ago. But write it as answer and you will get the reps – A.S. Nov 19 '13 at 18:59

1 Answers1

5

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.

Ming Li
  • 15,672
  • 3
  • 37
  • 35
  • 1
    Hi MingLi, I got same problem. Could you tell me how to separate READ and PUBLISH permission, because when I separated them into setReadPermission and setPublishPermission, it come into error. My request permission: authButton.setReadPermissions(Arrays.asList("basic_info, user_friends, read_friendlists, manage_friendlists")); – tana Jun 04 '14 at 06:20
  • Note: When I use this app, It's OK. But when other one use it, it's come to "The proxied app cannot request publish permissions without having being installed previously" – tana Jun 04 '14 at 06:29
  • @tana did you got solution for differentiate permissions. Please share. – Kalu Khan Luhar Dec 17 '14 at 05:40
  • I found that I must get approval from facebook before sharing my app to friend. – tana Dec 18 '14 at 02:41