django-socialregistration / README.rst

The default branch has multiple heads

Django Social Registration

Django Social Registration enables developers to add alternative registration methods based on third party sites.

Requirements

Installation

  1. Add the socialregistration directory to your PYTHON_PATH.
  2. Add socialregistration to your INSTALLED_APPS settings of Django.
  3. Add socialregistration.urls to your urls.py file.

Configuration

Facebook Connect

  1. Add FACEBOOK_API_KEY and FACEBOOK_SECRET_KEY to your settings file representing the keys you were given by Facebook.

  2. Add socialregistration.auth.FacebookAuth to AUTHENTICATION_BACKENDS in your settings file.

  3. Add socialregistration.middleware.FacebookMiddleware to MIDDLEWARE_CLASSES in your settings file.

  4. Add tags to your template file:

    {% load facebook_tags %}
    {% facebook_button %}
    {% facebook_js %}
    

Twitter

  1. Add the following variables to your settings.py file with the values you were given by Twitter:

    TWITTER_CONSUMER_KEY
    TWITTER_CONSUMER_SECRET_KEY
    TWITTER_REQUEST_TOKEN_URL
    TWITTER_ACCESS_TOKEN_URL
    TWITTER_AUTHORIZATION_URL
    
  2. Add socialregistration.auth.TwitterAuth to your AUTHENTICATION_BACKENDS settings.

  3. Add tags to your template file:

    {% load twitter_tags %}
    {% twitter_button %}
    

Other OAuth Services

Please refer to the Twitter implementation of the signup / login process to extend your own application to act as a consumer of other OAuth providers. Basically it's just plugging together some urls and creating an auth backend, a model and a view.

OpenID

  1. Add socialregistration.auth.OpenIDAuth to AUTHENTICATION_BACKENDS in your settings.

  2. Add tags to your template file:

    {% load openid_tags %}
    {% openid_form %}
    

Logging users out

You can use the standard {% url auth_logout %} url to log users out of Django. Please note that this will not log users out of third party sites though. Logging out a Facebook user might look something like this:

<a href="#" onclick="javascript:FB.logout(function(response){ document.location = '{% url auth_logout %}' })">Logout</a>

To log users out of other third party sites, I recommend redirecting them further to the OAuth / OpenID providers after they logged out of your site.

HTTPS

If you wish everything to go through HTTPS, set SOCIALREGISTRATION_USE_HTTPS in your settings file to True.

Other Information

If you don't wish your users to be redirected to the setup view to create a username but rather have a random username generated for them, set SOCIALREGISTRATION_GENERATE_USERNAME in your settings file to True.

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.