Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/viniciuschagas/djalf


https://github.com/viniciuschagas/djalf

Last synced: 3 months ago
JSON representation

Awesome Lists containing this project

README

        

djalf
===

Djalf is an application built on top of [alf](https://github.com/globocom/alf). It implements a custom token manager that stores the access token in the django's cache backend. This is useful for applications running with more than one process (with gunicorn, for example).

Using the django's cache, the application can share the access token among Its process, reducing the number of transactions with the API.

Installation
===

First you should install [alf](https://github.com/globocom/alf)

$ pip install -e git+https://github.com/globocom/alf#egg=alf

You can install from github:

$ pip install -e git+https://github.com/viniciuschagas/djalf#egg=djalf

or from source:

$ git clone https://github.com/viniciuschagas/djalf.git
$ cd djalf
$ python setup.py install

Usage
===

You should instantiate a django client object and use this object to perform your API calls.

>>> from djalf.client import ClientDjango
>>> from requests.packages.urllib3.util import Retry # only with alf >=0.6.0

>>> api_client = ClientDjango(
... token_endpoint='http://your-token-end-point',
... client_id='your-client-id',
... client_secret='you-client-secret',
... token_retry=Retry(total=5, status_forcelist=[500], backoff_factor=0.3) # only with alf >=0.6.0
...)

>>> api_client.get('http://your-api-resource')