Django Social Registration enables developers to add alternative registration methods based on third party sites.
Note
- django
- oauth2
- python-openid
- pyfacebook
- Add the
socialregistrationdirectory to yourPYTHON_PATH. - Add
socialregistrationto yourINSTALLED_APPSsettings of Django. - Add
socialregistration.urlsto yoururls.pyfile.
Add
FACEBOOK_API_KEYandFACEBOOK_SECRET_KEYto your settings file representing the keys you were given by Facebook.Add
socialregistration.auth.FacebookAuthtoAUTHENTICATION_BACKENDSin your settings file.Add
facebook.djangofb.FacebookMiddlewaretoMIDDLEWARE_CLASSESin your settings file. See: http://wiki.developers.facebook.com/index.php/User:PyFacebook_Tutorial#Add_the_middlewareAdd tags to your template file:
{% load facebook_tags %} {% facebook_button %} {% facebook_js %}If you want to use the pyfacebook library to do API calls to Facebook, add
socialregistration.middleware.FacebookMiddlewareto yourMIDDLEWARE_CLASSESsetting.
Add the following variables to your
settings.pyfile 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
Add
socialregistration.auth.TwitterAuthto yourAUTHENTICATION_BACKENDSsettings.Add tags to your template file:
{% load twitter_tags %} {% twitter_button %}
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.
Add
socialregistration.auth.OpenIDAuthtoAUTHENTICATION_BACKENDSin your settings.Add tags to your template file:
{% load openid_tags %} {% openid_form %}
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. When using Facebook Connect, it is recommended to follow the FBConnect developer wiki. See: http://wiki.developers.facebook.com/index.php/Connect/Authorization_Websites#Logging_Out_Users
<a href="#" onclick="FB.Connect.logoutAndRedirect('{% 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.
If you wish everything to go through HTTPS, set SOCIALREGISTRATION_USE_HTTPS in your settings file to
True.
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.