TL;DR version: Here is an app to allow logging in via twitter, facebook, openid, yahoo, google, which should work transparently with Django authentication system. (@login_required, User and other infrastructure work as expected.) Demo and Code.Longer version follow:
We are releasing our new app. Django-Socialauth. This app makes it awfully easy, to allow users to login your site using Yahoo/Google/Twitter/Facebook/Openid. A demo is available here.
This is released under an Attribution Assurance License. A copy of the same is provided included with the code.
After installing this app, you can use @login_required on any view and users identified via any means can access protected content.
We provide services to integrate and implement this, for a low price of USD 1600. Please contact us at licenses@uswaretech.com to discuss your exact needs.
The README is copied here for convenience.
What it does.
Allow logging in via various providers.
Logging In
This is a application to enable authentication via various third party sites. In particular it allows logging in via
- Gmail
- Yahoo(Essentially openid)
- OpenId
Libs you need to install
- python-openid (
easy_install) - python-yadis (
easy_install) - python-oauth(
easy_install)
The API Keys are available from
- http://www.facebook.com/developers/createapp.php
- https://developer.yahoo.com/dashboard/createKey.html
- https://www.google.com/accounts/ManageDomains
- http://twitter.com/oauth_clients
How it works.
Openid: Users need to provide their openid providers. Talk to the providers and
login.
Yahoo: Yahoo is an openid provider. Talk to Yahoo endpoints. (Endpoint: http://yahoo.com)
Google: Google is a provider. Talk to them. (Endpoint: https://www.google.com/accounts/o8/id)
Facebook: Facebook connect provides authentication framework.
Twitter: We use Twitter Oauth for authentication. In theory, Oauth shouldn’t be
used for authentication. (It is an autorisation framework, not an authentication one),
In practice it works pretty well. Once you have an access_token, and a name, essentially
authenticated.
References
- Demo of app
- Code for app
- http://openid.net/developers/
- http://developer.yahoo.com/openid/
- http://code.google.com/apis/accounts/docs/OpenID.html
- http://apiwiki.twitter.com/OAuth-FAQ
- http://developers.facebook.com/connect.php
Below the hoods
- For all providers(except Facebook) there are two urls and views. (start and done)
- Start sets up the required tokens, and redirects and hands off to the correct provider.
- Provider handles authentication on their ends, and hands off to Us, providing authorization tokens.
- In done, we check if the user with these details already exists, if yes, we log them in. Otherwise we create a new user, and log them in.
For all of these, we use standard django authenication system, with custom
auth_backends, hence all existing views, and decorators as login_required
will work as expected.
Urls
/login/ Login page. Has all the login options
/openid_login/ AND /openid_login/done/
/yahoo_login/ AND /yahoo_login/done/
/gmail_login/ AND /gmail_login/done/
/twitter_login/ AND /twitter_login/done/
/facebook_login/done/ We dont have a start url here, as the starting tokens are
set in a popup, as per FB Connect recommendations.
Implementation
- Install required libraries.
- Get tokens and populate in localsettings.py
- Set the token callback urls correctly at Twitter and Facebook.
- Add the OpenId middleware. Set the Authentication backends. (Set in localsettings.example.py)
Related posts:

{ 14 trackbacks }
{ 120 comments… read them below or add one }
← Previous Comments
StartupNews: Django-SocialAuth – Login via twitter, facebook, google, etc. from single app http://bit.ly/NELFB
This comment was originally posted on Twitter
Depending on what you want it for, I’ve had good experiences with django-authopenid ( bitbucket.org/benoitc/django-authopenid ).It doesn’t have the facebook or twitter, but it does work well with most openid providers (google, yahoo, etc). Plus, it lets users go ahead and just create a normal login if they don’t want to use openid.
There’s an example at openid-example.e-engura.org if you’re interested.
This comment was originally posted on Hacker News
Django-SocialAuth – Login via twitter, facebook, openid, yahoo, google using a single app. — The Uswaretech Blog – Djan http://bit.ly/Qwp3y
This comment was originally posted on Twitter
Blog| Django-SocialAuth – Login via twitter, facebook, openid, yahoo …:
TL;DR version: Here is an app.. http://bit.ly/N7zZQ
This comment was originally posted on Twitter
Chrome/IE8 actually do a reasonable job of addressing this by greying out everything but the domain in the address bar. Its something I’d like to see in FF — if anyone knows of an add-on to do this let me know.
This comment was originally posted on Hacker News
One challenge I have with all these logins options is that it becomes hard to remember which provider you logged in with. We have an issue already with Facebook connect and standard Django auth of duplicate accounts for a single user being created. Often times merging these can be rough. Has anyone come up with an elegant solution to this problem?
This comment was originally posted on Hacker News
Pretty closely integrated, as I wanted a seamless experience as close to normal django auth in part. But talking to providers is generic. Let me know if you would need my help porting this to Pytlons.
This comment was originally posted on Hacker News
#greader [django community] Shabda Raaj: Django-SocialAuth – Login via twitter, facebook, openid, yahoo,.. http://bit.ly/OcLWN
This comment was originally posted on Twitter
Django-SocialAuth: Login via twitter, facebook, openid, yahoo, google using a single app: http://twurl.nl/gm6bvu
This comment was originally posted on Twitter
Django-SocialAuth – Login via twitter, facebook, openid, yahoo, google using a single app. — The Uswaretech Blog – .. http://short.to/o9mh
This comment was originally posted on Twitter
Django-SocialAuth – Login via twitter, facebook, openid, yahoo, google using a single app. — The Uswaretech Blog – Dj.. http://is.gd/2DDbC
This comment was originally posted on Twitter
Django-SocialAuth – Login via twitter, facebook, openid, yahoo, google using a single app – http://bit.ly/15dgpA
This comment was originally posted on Twitter
Locationbar²!https://addons.mozilla.org/en-US/firefox/addon/4014
This comment was originally posted on Hacker News
Django-SocialAuth Login via #twitter #facebook #openid #yahoo #google in a one app. would be cool for #pinax http://tr.im/xoWi
This comment was originally posted on Twitter
Django-SocialAuth – Login via twitter, facebook, openid, yahoo, google using a single app. http://bit.ly/EvP97
This comment was originally posted on Twitter
Django-SocialAuth – Login via twitter, facebook, openid, yahoo …: TL;DR version: Here is an app to allow loggi.. http://bit.ly/OcLWN
This comment was originally posted on Twitter
Django-SocialAuth http://tinyurl.com/mwu43g – Django-SocialAuth – Login via twitter, facebook, openid, yahoo, google using a single app.
This comment was originally posted on Twitter
Django-SocialAuth – Login via twitter, facebook, openid, yahoo, google using a single app – http://tinyurl.com/mwu43g
This comment was originally posted on Twitter
Nice, thank you..
This comment was originally posted on Reddit
http://tinyurl.com/mwu43g
Django-SocialAuth – Login via twitter, facebook, openid, yahoo, google using a single app. — The Usware Blog …
This comment was originally posted on Twitter
← Previous Comments