The tribe_client package¶
This python package allows web servers created using the Django web framework to connect directly to Tribe and make use of its resources. Users of the client web server can login to access their Tribe resources via Tribe OAuth 2.0 authentication.
Download and Install¶
Tribe-client is registered as “django-tribe-client” in PyPI and is pip installable:
pip install django-tribe-client
Source¶
The source for tribe-client can be found here: https://bitbucket.org/greenelab/tribe-client
Quick Start¶
- Add
tribe_client
to yourINSTALLED_APPS
setting:
INSTALLED_APPS = (
...
'tribe_client',
)
- Include the tribe-client URLconf in your project’s URLconf (usually
urls.py
):
from django.conf.urls import url, patterns, include
urlpatterns = patterns('',
...
(r'^tribe_client/', include('tribe_client.urls')),
)
- Register your client server at https://tribe.greenelab.com/oauth2/applications/. Make sure to:
- Be logged-in using your Tribe account
- Select “Confidential” under
Client type
and- Select “Authorization Code” under
Authorization grant type
- Enter your client server’s address plus “/tribe_client/get_token” in the
Redirect uris
box. If your client server’s current address is http://example.com, enter http://example.com/tribe_client/get_tokenNote
Currently, Tribe supports the following
Authorization grant types
:
- Authorization code
- Resource owner password-based
and does not support the following:
- Implicit
- Client credentials
- Write down the Client ID in the
TRIBE_ID
setting and the Client secret in theTRIBE_SECRET
setting in yoursettings.py
file like so:
TRIBE_ID = '*****Tribe Client ID*****'
TRIBE_SECRET = '*****Tribe Client Secret*****'
- The
TRIBE_REDIRECT_URI
setting should be the address of the client server plus “/tribe_client/get_token”.
TRIBE_REDIRECT_URI = 'http://example.com/tribe_client/get_token'
- Make sure that you have a
base.html
template that the tribe_client templates can extend - Make a link that takes the user to the
/tribe_client
url of your website for them to log in using Tribe
A Closer Look¶
Under the hood, tribe-client has functions that:
- Get an access token (via the OAuth2 protocol) that allows users to access and create resources in Tribe.
- Retrieves public and private collections (and their versions) and displays them on the client server using views and templates included in the package.
- Allows users to create new collections and versions remotely, from the client server