Skip to content

API authentication

Fred Blundun edited this page Feb 12, 2016 · 4 revisions

HOME > IGLU TECHNICAL DOCUMENTATION > IGLU REPOSITORIES > API authentication

3. API authentication

In order to use both the schema service and the validation service you will need an API key which will have to be passed as a HTTP header named apikey with each and every one of your request to those services.

To get those API keys, you will need to request them to the administrator of the Iglu repository you are using. This administrator should give you back two keys: one with readonly access and the other with both read and write access. Consequently, you will be able to make POST and PUT requests only with the API key having read and write access.

Those API keys will belong to an owner which will have to be, in the case of the schema service, a prefix of the schema's vendor.

For example, let’s say you work for Acme Inc, and so the administrator of the Iglu repository you are using gives you a pair of keys for the com.acme vendor prefix. One of those API key will have read access and consequently will let you retrieve schemas through GET requests, the other will have both read and write access so you will be able to publish and modify schemas through POST and PUT requests in addition to being able to retrieve them. It is then up to you on to distribute those two keys however you want. Those keys grants you access to every schema whose vendor starts with com.acme.

As a concrete example, let’s say you request API keys to the aforementionned administrator and you get back this couple of API keys:

`663ee2a1-98a2-4a85-a05b-20f343e4961d` for read access
`86da37e8-fdac-406a-8c71-3ae964e75882` for both read and write access

Using the second API key you will be able to create schemas, the vendor of which starts with com.acme:

curl \
  HOST/api/schemas/com.acme.project1/ad_click/jsonschema/1-0-0 \
  -X POST \
  -H "apikey: 86da37e8-fdac-406a-8c71-3ae964e75882" \
  -d "{ \"your\": \"json\" }"

And you will be able to retrieve this schema with either one of those API keys:

curl \
  HOST/api/schemas/com.acme.project1/ad_click/jsonschema/1-0-0 \
  -X GET \
  -H "apikey: 663ee2a1-98a2-4a85-a05b-20f343e4961d"

Clone this wiki locally