Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to integrate social-auth in my project

Tags:

django

I want to use social-auth to provide registration/authentication via social network sites. I have been trying to understand how to use social-auth, but I have been unable to get beyond installing dependencies and configuring backends.

I am basically new to Django and I have tried hard to understand before posting on the forum. Maybe because I am not very familiar with it that is why I have been unsuccessful. Can anybody please point me to a tutorial on how to use social-auth. This will also help me in integrating other apps.

Update:

Although the answer given below solved my problem, I just want to share that I ended up using django-allauth instead of social-auth. And the latest version of django-allauth appears to be the best Django authentication app.

like image 771
Sachin Avatar asked Oct 23 '11 16:10

Sachin


1 Answers

It's somehow unclear from documentation.

You need to create apps in Twitter/Facebook/whatever you want to use.

  • If you want twitter see: https://dev.twitter.com/apps/new
  • If you want facebook: https://developers.facebook.com/apps

They will give you api key and api secret.

Follow these basic steps that refer to socialauth docs:

  1. pip install
  2. add social-auth to installed apps
  3. copy AUTHENTICATION_BACKENDS
  4. fill api key and api secret
  5. add social auth url patterns
  6. configure authentication and association complete URL names (SOCIAL_AUTH_COMPLETE_URL_NAME)
  7. context processor
  8. syncdb

Now, what the documentation doesn't tell you, is to put links in your login template:

Login with <a href="{% url socialauth_begin 'twitter' %}">Twitter</a>

Should work.

like image 59
3 revs Avatar answered Oct 03 '22 06:10

3 revs