I have a Django project running django-rest-framework
to provide a backend for BackboneJS application. I am trying to implement python-social-auth
to authenticate the app via AJAX.
I need to send via AJAX a list of possible login urls to render in the BackboneJS view e.g.
{ 'login_urls' : [
"https://mydjangoserver.com/login/google-oauth2/",
"https://mydjangoserver.com/login/facebook/",
...]
}
but to do this I need access this data on the backend in Django. I can access the AUTHENTICATION_BACKENDS
setting but this only gives a list of strings containing references to modules - how would I convert these to urls?
Thanks to the heads up from mariodev, the buried social.backends.utils
module contains a function to extract the backends from the configured settings ...
from social.backends.utils import load_backends
import myprojectname.settings as settings
backends = load_backends(settings.AUTHENTICATION_BACKENDS)
login_urls = ['//%s/login/%s/' % (settings.MY_SERVER_HOSTNAME, name) for name in backend.keys()]