Installation¶
Installing and integrating Django Linked Accounts requires the following steps:
- Install Dependencies
- Install Django App
- Include URLs
- Add Authentication Backend
- Obtain Service Keys
- Add Settings
Install Dependencies¶
Django Linked Accounts depends on django-oauth-flow.
You can run the following commands through pip install
to install
the necessary dependencies:
-e git://github.com/zen4ever/django-oauth-flow.git#egg=django-oauth-flow
httplib2>=0.6.0
oauth2>=1.5.167
Or use supplied requirements.txt
file:
git clone git://github.com/zen4ever/django-linked-accounts.git
cd django-linked-accounts/
pip install -r requirements.txt
You can install the python package with the following:
pip install -e git://github.com/zen4ever/django-linked-accounts.git
Install Django App¶
Add linked_accounts
to your INSTALLED_APPS
(settings.py
):
INSTALLED_APPS = (
# ...
"linked_accounts",
)
Include URLs¶
Include URLs for linked_accounts
in your URLconf (urls.py
):
urlpatterns = patterns("",
# ...
url(r"^linked_accounts/", include("linked_accounts.urls"))
)
Add Authentication Backend¶
Add the custom authentication backend to your
AUTHENTICATION_BACKENDS
(settings.py
) to allow OAuth authentication
with Django Linked Accounts.
AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.ModelBackend',
'linked_accounts.backends.LinkedAccountsBackend',
)
Obtain Service Keys¶
You will need to obtain a KEY
and SECRET
with each third-party
service you want to support. Yes, it’s tedious. But, hey, you only have
to do it once for your app and you can piggyback on established social
graphs and make things easier for your users by importing information
already entered elsewhere.
Here are some handy reference links to get you started:
- Facebook: https://developers.facebook.com/apps (click the “Create New App” button...)
- Twitter: https://dev.twitter.com/apps/new
- Google: https://code.google.com/apis/console/
- Yahoo: https://developer.apps.yahoo.com/wsregapp
- LinkedIn: https://www.linkedin.com/secure/developer
Most of these services require you to register an authentication callback URL to redirect to after a user authorizes your app. Here’s an example callback URL for Twitter:
http://yourdomain.com/linked_accounts/complete/twitter/
Add Settings¶
Lastly, add OAuth settings in your settings.py
for each service
you want to integrate with using the KEY
and SECRET
values
you obtained in the previous installation step.
Use the following code as a reference and include only the services you want to support:
OAUTH_FLOW_SETTINGS = {
'facebook': {
'KEY': '',
'SECRET': '',
'SCOPE': ['email'],
},
'twitter': {
'KEY': '',
'SECRET': '',
},
'google': {
'KEY': '',
'SECRET': '',
'SCOPE': ['https://www.googleapis.com/auth/userinfo.profile']
},
'yahoo': {
'KEY': '',
'SECRET': '',
}
}