sanddeep
sanddeep

Reputation: 31

How to set extra permissions using the Facebook JavaScript SDK

I am using the following Facebook JavaScript code to open the Facebook login dialog. This code is working fine and is also asking for permissions. How can I add extra permissions?

<fb:login-button autologoutlink="true" onlogin="OnRequestPermission();">
</fb:login-button>
<script language="javascript" type="text/javascript">
    FB.init({
        appId: 'AppId',
        status: true,
        cookie: true,
        xfbml: true
    });
</script>

This is asking only to assess the basic profile. I also want to manage page and groups. How can I set the permissions for the following?

Upvotes: 2

Views: 3120

Answers (2)

Abby
Abby

Reputation: 3209

If you are using OAuth 2, which you should be aiming for (as 'perms' won't work after Oct 1st), you need something like this:

FB.login(function(response) {
    if (response.authResponse) {
        alert('Logged in and accepted permissions!');
    }
}, {scope:'manage_pages,publish_stream'});

Upvotes: 3

Christophe Henner
Christophe Henner

Reputation: 24

You have to add the perms parameter in your <fb:login-button> and add the extended permissions as values separated by a comma.

For instance, asking for the read_stream permission would look like:

<fb:login-button autologoutlink="true" onlogin="OnRequestPermission();" perms="read_stream">
</fb:login-button>

Upvotes: 0

Related Questions