Allow user passes on Facebook Auth Dialogue Javascript SDK

I have an application on a page tab that uses facebook javascript sdk. When a new user enters the application, I get the expected "Login to facebook" popup. I also have some advanced permissions that I entered in the FB.Login scope parameter. After users log in with facebook, I see a pop-up window with advanced permissions. The only problem is that the user skips extended permissions, the dialog returns access_token back, but it is not valid for extended permissions. Sample code below.

window.fbAsyncInit = function () {
    FB.Canvas.setAutoGrow();
    FB.init({
        appId: facebookAppId, 
        status: true, // check login status
    });

    function updateFBInfo(response) {
        console.log('updateResp:');
        if (response.authResponse) {
            //user is already logged in and connected
            FB.api('/me', function (info) {
                displayUserInfo(info, response);
            });
        }
        else {
            FB.login(function (loginResponse) {
                if (loginResponse.authResponse) {
                    FB.api('/me', function (info) {
                        displayUserInfo(info, loginResponse);
                    });
                }
            }, { scope: 'email,manage_pages,offline_access,publish_stream' });
        }
    }

    FB.getLoginStatus(updateFBInfo);
};

, , ( - ), , acces_token ?

+3
1

, . , FB.login() .

:

FB.api('/me/permissions', function (response) {
            var perms = response.data[0];
            // Check for publish_stream permission in this case....
            if (perms.publish_stream) {                
                // User has permission
            } else {                
                // User DOESN'T have permission. Perhaps ask for them again with FB.login?
            }                                            
    } );
+9

All Articles