views:

101

answers:

4

I want to let users use their google account to login to my website. Exactly the way SO lets me. Can anyone please point in the right direction? I'm assuming the oAuth library is to be used but what I'd really like is a snippet of code I can directly copy paste and get this to work.

+1  A: 

You may want to check out django-piston which is a mini-framework with oAuth built in. Here's a tutorial on how to set it up.

Soldier.moth
+2  A: 

It's not OAuth particularly that you need (OAuth is for authorising access for one website to specific private content held on another), but OpenID - which is meant for authentication rather than authorisation. (Some sites, like Twitter, do provide authentication services via OAuth, but that's not what it's primarily for.) I have used python-openid which is fairly straightforward to use, or you can look at django-openid - though it admits to being incomplete, you could get some idea of how to implement OpenID support.

The problem's a little too involved to admit a copy-and-paste solution, but it's not especially hard to do this.

Update: piquadrat's link (in he comment) is definitely worth following.

Vinay Sajip
I've written a somewhat comprehensive compilation of OpenID auth backends for Django in a question of mine: http://stackoverflow.com/questions/2123369/whats-the-best-solution-for-openid-with-django
piquadrat
I ended up using django_authopenid.
Gaurav
+2  A: 

This is what I was looking for:

http://www.linuxuser.at/how-i-finally-got-openid-and-django-working-together

Thanks.

Gaurav
A: 

You might consider using Django-Socialauth, as it supports

  • Twitter
  • Gmail
  • Facebook
  • Yahoo (essentially openid)
  • OpenId
Chris Lawlor