This repository was archived by the owner on Dec 26, 2023. It is now read-only.
forked from agiliq/Django-Socialauth
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathREADME
90 lines (71 loc) · 3.21 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
What it does
-----------------
This is a application to enable authentication via various third party sites.
In particular it allows logging in via
Twitter
Gmail
Facebook
Yahoo(Essentially openid)
OpenId
How it works
-------------------
1. For all providers(except Facebook) there are two urls and views. (start and done)
2. Start sets up the required tokens, and redirects and hands off to the correct
provider.
3. Provider handles authentication on their ends, and hands off to Us, providing
authorization tokens.
4. 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.
API References
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
Limitations
--------------
As with all APIs, we are limited by the amout of data which the API provider
provides us. For example, both Yahoo and Google provide extremely limited data
about the autheticated subscriber. Twitter and Facebook provide a lot of details,
but not the email. Different Openid providers are free to provide [different
amounts of data](http://openid.net/specs/openid-simple-registration-extension-1_0.html).
Implementation
----------------
1. Install required libraries.
`pip install python-openid python-yadis oauth`
2. Add `socialauth` to `INSTALLED_APPS`
3. Include required urls
`(r'^accounts/', include('socialauth.urls')),`
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.
4. Add required settings
OPENID_REDIRECT_NEXT = '/accounts/openid/done/'
OPENID_SREG = {"requred": "nickname, email", "optional":"postcode, country", "policy_url": ""}
OPENID_AX = [{"type_uri": "email", "count": 1, "required": False, "alias": "email"}, {"type_uri": "fullname", "count":1 , "required": False, "alias": "fullname"}]
TWITTER_CONSUMER_KEY = ''
TWITTER_CONSUMER_SECRET = ''
FACEBOOK_API_KEY = ''
FACEBOOK_API_SECRET = ''
LOGIN_REDIRECT_URL = '/login/done/'
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
5. Set the authentication_backends to the providers you are using.
AUTHENTICATION_BACKENDS = ('django.contrib.auth.backends.ModelBackend',
'socialauth.auth_backends.OpenIdBackend',
'socialauth.auth_backends.TwitterBackend',
'socialauth.auth_backends.FacebookBackend',
)
6. If using them, set the token callback urls correctly for Twitter and Facebook.