开发者

use python / django to let users login to my site using their google credentials

I want to let users use their google account to login to my website. Exactly the way 开发者_如何学PythonSO 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.


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.


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.


You might consider using Django-Socialauth, as it supports

  • Twitter
  • Gmail
  • Facebook
  • Yahoo (essentially openid)
  • OpenId
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜