I am using the Facebook Javascript SDK to log users into my site. This works and I am able to request permissions when they log in.
However, as recommended by Facebook, I would like to only request the most basic permissions at login and then request extra permissions as and when they are required as not all users will require e.g. publish permissions.
My question is how do I request additional permissions? The only way to request permissions that I can see in the docs is to do it at login. This post suggests just calling FB.login()
again:
FB.login(function(response) {
// ...do some stuff
}, {
scope: ['publish_actions']
});
...but doing that gives me an error: FB.login() called when user is already connected
. Most other posts on the subject just say to request all the permissions at login - but that goes against FB's own recommendations.
Plan your app around requesting the bare minimum of read permissions at initial login and then any publish permissions when a person actually needs them
(From the FB Docs)
Apart from the error, calling FB.login()
does appear to work correctly but if it's explicitly causing an error then surely this isn't the right way to go about it. Am I missing something?
You are not using it in a correct way:
FB.login(function(response) {
// handle the response
}, {
scope: 'publish_actions,some_other_permission',
auth_type: 'rerequest'
});
It´s not an array, it´s just a string. And you should try with the auth_type parameter. Source: https://developers.facebook.com/docs/facebook-login/login-flow-for-web/v2.3#re-asking-declined-permissions
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With