Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

django login with google app acoounts

Well, I thought this shouldn't be a big problem. However, since I have spent more than one day on this, I think it is the time for asking help.

I have a simple django admin project and it works fine now. The problem is that I want to implement the feature that only allow the user login my admin site with particular google app domain, like @example.com. Then users doesn't have to manually create account and it is easy for me to manage users.

I believe this is a common feature required by many websites. So I do some search and I found some posts introduce some interesting libraries.

The post here are helpful:

Google apps login in django

What's the best solution for OpenID with Django?

Which openid / oauth library to connect a django project to Google Apps Accounts?

The last one the one I think should work for me, but it doesn't.

I have installed the python-openid patch from adieu on github:https://github.com/adieu/python-openid and it still give the same error: 'OpenID authentication failed: HTTP Response status from identity URL host is not 200. Got status 404'

After some diggings, I cannot figure out the solution.

Then I start looking for 'Google Accounts Authentication and Authorization' see if I can build the whole thing by myself.

Now, my question, should I keep sticking on the exist django libraries or should I starts doing something from the beginnings.

So the ideal solution is either some hint for solving the error on python-openid or give the direction for next move (new libraries or Google Accounts Authentication and Authorization)

Thanks in advance!

like image 944
Jerry Meng Avatar asked May 16 '13 14:05

Jerry Meng


1 Answers

Based on my experience, best thing you can use is python-social-auth. Python social auth generates user with its own structure but you can define pipeline and say that whenever python-social-auth creates new user, you can also create django user.

like image 172
Brkyrn Avatar answered Nov 16 '22 02:11

Brkyrn