Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook (FB.login) not requesting my permissions

so after updating to the php 3.0 sdk and what not, my FB.login() function no longer asks for the permissions I set it to ask. Any one else getting this? Here's some code for you:

window.fbAsyncInit = function() {
  FB.init({
    appId: 'xxx',
    status: true,
    cookie: true,
    xfbml: true,
    oauth : true // enables OAuth 2.0
  });
  // whenever the user logs in, we refresh the page
  //FB.Event.subscribe('auth.login', function() {
  //  window.location.reload();
  //});      
};


FB.login(function(response) {
  if (response.authResponse) {
    console.log('Welcome!  Fetching your information.... ');
    FB.api('/me', function(response) {
      console.log('Good to see you, ' + response.name + '.');
      FB.logout(function(response) {
        console.log('Logged out.');
      });
    });
  } else {
    console.log('User cancelled login or did not fully authorize.');
  }
}, {scope:'read_stream,publish_stream,offline_access'});

The way I'm trying to access it, is through an onClick="FB.login();". Can anyone help?

like image 672
Johny Avatar asked Aug 08 '11 22:08

Johny


Video Answer


2 Answers

Checking the source of the JS SDK I found that they still use perms and not scope as it it documented. This is working for me:

...onclick="FB.login(handleLoginResponse, {perms:'email,manage_pages,user_birthday'});return false;"...

I hope it helps.

like image 137
Tibor Avatar answered Oct 17 '22 09:10

Tibor


I see something related to this with the JS SDK. When setting oauth=true, the function

FB.login(function (response) {
    if (response.authResponse) {
        console.log('Welcome!  Fetching your information.... ');
    } else {
    console.log('User cancelled login or did not fully authorize.');
}
}, { scope: 'email,publish_stream,user_birthday,user_location' });

Correctly requests the extended permissions, but using the <fb:login-button> FBXML with scope="email,publish_stream,user_birthday,user_location" does not.

This looks like a Facebook bug to me...

like image 35
Rolf Avatar answered Oct 17 '22 08:10

Rolf