[Answered ]-Django-social-auth: How can I implement more provider?

2πŸ‘

βœ…

A backend like this should do the work:

from social_auth.backends.facebook import FacebookAuth, FacebookBackend

class FacebookBackendForAdmins(FacebookBackend):
    name = 'facebook-admins'

class FacebookAuthForAdmins(FacebookAuth):
    AUTH_BACKEND = FacebookBackendForAdmins
    SCOPE_VAR_NAME = 'FACEBOOK_ADMIN_EXTENDED_PERMISSIONS'

Then define the setting:

FACEBOOK_ADMIN_EXTENDED_PERMISSIONS = ['email', 'publish_stream', 'manage_pages']

And don’t forget the setting for non-admin users:

FACEBOOK_EXTENDED_PERMISSIONS = ['email', 'publish_stream']

And also add it to AUTHENTICATION_BACKENDS setting (assuming that you add that code into yourapp/facebook_backend_for_admins.py):

AUTHENTICATION_BACKENDS = (
    ...
    'yourapp.facebook_backend_for_admins.FacebookBackendForAdmins',
    ...
)
πŸ‘€omab

Leave a comment