Skip to content

Configuration

Jakub Gocławski edited this page Sep 25, 2017 · 3 revisions

To configure your api use:

api = jsonapi_requests.Api.config({
    'API_ROOT': 'https://localhost/api/2.0',
    'AUTH': ('basic_auth_login', 'basic_auth_password'),
    'VALIDATE_SSL': False,
    'TIMEOUT': 1,
})

Your configuration options are:

  • API_ROOT - the root of your endpoints. This is mandatory.
  • AUTH - HTTP_AUTH header. This is passed as auth parameter to underlying requests library. Check http://docs.python-requests.org/en/master/user/authentication/ for viable options. Default is None.
  • VALIDATE_SSL - You can disable ssl validation by setting it to False. Default is True.
  • TIMEOUT - How long we wait for server to respond before raising exception. This is passed to underlying requests library. Check http://docs.python-requests.org/en/master/user/quickstart/#timeouts. Default is 1.
  • APPEND_SLASH - Append slash if url does not append with slash. Default is True.
  • RETRIES - Before ApiConnectionError or ApiInternalServerError is raised request is tried this many times. 1 means no tries. Default is 3.

When using jsonapi_requests with Flask, we can set jsonapi_requests.auth.FlaskForwardAuth() as AUTH configuration option to copy authorization header from current request context. It can be useful when fetching resources from different microservices. Check README.md for details.

Clone this wiki locally