Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scope parameter is ignored by facebook login

I am trying to use Facebooks PHP SDK to login to my page. However, Facebook ignores the permissions given as an array in getLoginUrl()

$loginUrl = $helper->getLoginUrl(
    ['publish_actions']
);

The login url looks like:

https://www.facebook.com/v2.3/dialog/oauth?client_id=206265226055767&redirect_uri=http://host.tld/remote/gateway.php&state=67096befe627aa603cb086da681626c1&sdk=php-sdk-4.0.23&scope=publish_actions

However, Facebook still ask for my public_profile and my email

  • I have administrator privileges
  • The app is still in development mode

My Question is why Facebook ignores the scope parameter on the oauth login dialog.

like image 943
CREA Nico Wehmöller Avatar asked Oct 19 '22 09:10

CREA Nico Wehmöller


1 Answers

Try with this code:

$params = array(
  'scope' => 'publish_actions',
  'redirect_uri' => 'https://www.myapp.com/post_login_page'
);

$loginUrl = $facebook->getLoginUrl($params);

Not sure if it works the same way with the PHP SDK 4.x though, but you can try this:

$scope = array('publish_actions');
$loginUrl = $helper->getLoginUrl($scope);

...from the well upvoted answer in this thread: Specify app scopes in php facebook sdk 4.0.0 or greater

Of course you can also write it like this:

$loginUrl = $helper->getLoginUrl(array('publish_actions'));

Not sure if it helps in your case, the literal array definition should definitely work in PHP...but you never know ;)

like image 61
andyrandy Avatar answered Oct 27 '22 22:10

andyrandy