Reputation: 1680
I am using django-allauth in my Django application.
Every user has an option to connect his/her Facebook account to their existing account. I was able to to do this by adding allauth's connect process.
<a href='{% provider_login_url "facebook" process="connect" %}'>
Connect with Facebook
</a>
At this point, I don't want to ask for permission to post to the user's wall.
#settings.py
SOCIALACCOUNT_PROVIDERS = {
'facebook': {
'SCOPE': ['email'],
'METHOD': 'js_sdk'
}
}
All goes well and the user can connect a Facebook account.
But, is there a way to ask for permission to post on the user's wall separately? I don't want to ask for publish_actions permissions above.
How do I do this using django-allauth?
How do I ask for publish_actions permission separately? Can this be done using django-allauth? Because I am guessing this requires re-declaring 'SCOPE' for 'facebook' SOCIALACCOUNT_PROVIDERS in settings.py.
Thanks in advance
Upvotes: 3
Views: 1099
Reputation: 4806
In the SOCIALACCOUNT_PROVIDER
setting provided by django allauth http://django-allauth.readthedocs.io/en/latest/providers.html#facebook You would need to change the following section to include any extra permission you need
SOCIALACCOUNT_PROVIDERS = {
'facebook': {
'SCOPE': ['email', 'public_profile', 'publish_actions'], # add your permissions here
'METHOD': 'js_sdk',
...
}
}
Upvotes: 0
Reputation: 1680
I finally solved it. Turns out that django allauth saves the settings as JSON in the DOM element #allauth-facebook-settings. You just have to modify this json and pass to the allauth facebook init function. When the user clicks to enable a feature which requires 'publish_actions' permission, I call a Javascript function:
function modify_permissions() {
var json = JSON.parse($("#allauth-facebook-settings").html());
json["loginOptions"]["scope"] = "email, publish_actions";
allauth.facebook.init(json);
}
Now, if you try to connect a FB account from that page, django allauth will ask for 'publish_actions' permission too.
Upvotes: 3