Facebook (FB.login) not requesting my permissions

Viewed 15303

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?

6 Answers

I think its because you are calling FB.logout within the FB.login block.

Effectively what happens is as soon as they log in, they are logged out.

So seperate it like this:

// CALLED WHEN USER LOGS IN
function userLogin() {
    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 + '.');
            });
        } else {
            console.log('User cancelled login or did not fully authorize.');
        }
    }, {scope:'read_stream,publish_stream,offline_access'});
}

// CALLED WHEN USER LOGS OUT
function userLogout() {
    FB.logout(function(response) {
        console.log('Logged out.');
    });
}
Related