Django-Allauth Facebook Integration - Request permission to post on user's wall separately

I am using django-allauth in my Django app.

Each user has the ability to connect their Facebook account to an existing account. I was able to do this by adding an allauth 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'
    }
}

      

Everything is going well and the user can connect to their Facebook account.

But is there a way to ask permission to post on a user's wall separately? I don't want to ask for publish_actions permissions above.

How can I do this using django-allauth?

How can I request the publish_actions permission separately? Can this be done using django-allauth? Because I am guessing it requires re-declaring "SCOPE" for "facebook" SOCIALACCOUNT_PROVIDERS in settings.py.

Thank you in advance

+3


source to share


1 answer


I have finally decided. It turns out that django allauth stores settings as JSON in the # allauth-facebook-settings DOM element . You just need to change this json and go to allauth facebook init function. When the user clicks to enable a function that requires "publish_actions" permission, I call the 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 your FB account from this page, django allauth will also ask for the "publish_actions" permission.

+2


source







All Articles