skip to navigation
skip to content

Not Logged In

django-odesk-auth 0.1.0

A simple Django app for basic “Log in via oDesk” functionality.


Django app for simple “Log in via oDesk” functionality.
Authentication backend and a couple of views.

Creating oDesk OAuth API key

Go to

* Authentication type should be set to "OAuth 1.0".
* Callback URL should be left blank.
* Permission "View the structure of your companies/teams" is currently
required to be checked.

Quick start

Provided you have installed ``django-odesk-auth`` and ``python-odesk==0.5``.

1. Add ``django_odesk_auth`` to INSTALLED_APPS.
Make sure you have ``django.contrib.sites`` app in INSTALLED_APPS as well.

2. Add ``django_odesk_auth.backends.ODeskOAuthBackend``

3. Specify ``ODESK_OAUTH_KEY`` and ``ODESK_OAUTH_SECRET`` settings
with your key information.


5. Include ``django_odesk_auth.urls`` in your URL patterns.

6. In your login page template, put a link "Log in via oDesk" and point it
to ``{% url "odesk_oauth_login" %}``.

7. Open login page and click "Log in via oDesk" to verify everything works.

Important: keep ``ODESK_OAUTH_KEY`` and ``ODESK_OAUTH_SECRET`` settings in a file
that is not under version control.

Example project

Install ``django==1.6`` and ``python-odesk==0.5`` (better do this
in virtual Python environment created specifically for example project).

Fill in some critical settings in ``example_project/`` (see comments),
then run ``./ syncdb``, then you can run development server and
open ``localhost:8000``.

Access control

Currently there's no way to turn off access control: you have to explicitly
specify which teams or particular users are allowed to log in to your site.
You can also specify which users are assigned staff and superuser status
upon login.

Users that aren't allowed to log in get ``User.is_active`` flag set to False.

See ``utils.update_user_permissions()`` definition and list of settings below.

Making API calls after authentication

After user is successfully authenticated, you can make API calls on their behalf.

Here's a quick example::

from django_odesk_auth import utils, O_ACCESS_TOKEN
odesk_client = utils.get_client(request.session[O_ACCESS_TOKEN])
# Should output list of teams user has access to

Some notes:

* How you make API calls is up to you. Internally django-odesk-auth
uses python-odesk library, and so does this example.

* ``utils.get_client()`` function returns an instance of ``odesk.Client``.
Handy if you're using python-odesk library to make API calls.

* OAuth access token, obtained during authentication, is stored
under ``request.session[O_ACCESS_TOKEN]``.

Checking OAuth access token

Sometimes there's a need to make sure that current user's authentication
is still valid. You can use ``utils.check_login()`` in Python,
or make an HTTP request to named URL ``'odesk_oauth_check_login'``
from client side (see ``views.oauth_check_login``).

Available settings

API key information.

Whether to create a new account in Django if given user logs in via oDesk
for the first time.

oDesk emails of users who are allowed to log in via oDesk.

oDesk emails of users who are marked as ``is_staff`` upon login.

oDesk emails of users who are marked as ``is_superuser`` upon login.

IDs of oDesk teams, members of which are allowed to access FIVS backend.

IDs of oDesk teams, members of which are marked as ``is_staff`` upon login.

IDs of oDesk teams, members of which are marked as ``is_superuser`` upon login.  
File Type Py Version Uploaded on Size
django-odesk-auth-0.1.0.tar.gz (md5) Source 2014-03-07 7KB
  • Downloads (All Versions):
  • 6 downloads in the last day
  • 26 downloads in the last week
  • 83 downloads in the last month