Added projects endpoint docs, error status codes, token expiration description

pull/280/head
Piero Toffanin 2017-08-31 17:51:52 -04:00
rodzic 99a279e0f1
commit a25456d5fe
4 zmienionych plików z 30 dodań i 1 usunięć

Wyświetl plik

@ -2,6 +2,8 @@
## Authentication ## Authentication
### Authentication Basics
> Get authentication token: > Get authentication token:
```bash ```bash
@ -42,6 +44,13 @@ Header |
------ | ------ |
Authorization: JWT `your_token` | Authorization: JWT `your_token` |
The token expires after a set amount of time. The expiration time is dependent on WebODM's settings. You will need to request another token when a token expires. The token expires after a set amount of time. See [Token Expiration](#token-expiration) for more information.
Since applications sometimes do not allow headers to be modified, you can also authenticate by appending the `jwt` querystring parameter to a protected URL. This is less secure, so pass the token via header if possible. Since applications sometimes do not allow headers to be modified, you can also authenticate by appending the `jwt` querystring parameter to a protected URL. This is less secure, so pass the token via header if possible.
### Token Expiration
The token expires after a set amount of time. The expiration time is dependent on WebODM's settings. You will need to request another token when a token expires.
You know that a token has expired if any call to an API returns a `403` status code with the JSON body `{'detail': 'Signature has expired.'}`.

Wyświetl plik

@ -0,0 +1,16 @@
## Handling Errors
All API calls use the status codes as described in the [Django REST Framework's Status Code Guide](http://www.django-rest-framework.org/api-guide/status-codes/), but generally you only need to check for success status code (status code `200` or `204`) and handle the special case of [Token Expiration](#token-expiration) (status code `403`) and report an error otherwise.
### Error Status Codes
This is not an exhaustive list, but common error codes are listed below.
Status Code | Description
----------- | -----------
401 | Unauthenticated
403 | Forbidden (token expired?)
400 | Malformed request
404 | Not found
For security reasons, sometimes an operation which should return `403` returns `404` to avoid disclosing IDs and other information from attackers.

Wyświetl plik

@ -57,6 +57,9 @@ Parameters are the same as above.
Upon deletion, all [Task](#task) items associated with the [Project](#project) are deleted also. The operation is irreversible. Upon deletion, all [Task](#task) items associated with the [Project](#project) are deleted also. The operation is irreversible.
### Get single project
`GET /api/projects/{id}/`
### Get list of projects ### Get list of projects

Wyświetl plik

@ -19,6 +19,7 @@ includes:
- reference/task - reference/task
- reference/processingnode - reference/processingnode
- reference/permissions - reference/permissions
- reference/handlingerrors
- fordevelopers - fordevelopers
--- ---