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

天大地大妈咪最大 提交于 2019-12-06 01:06:17

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/20070153/facebook-sdk-apiexceptionthe-proxied-app-cannot-request-publish-permissions-w

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!