Users and Tokens¶
Token¶
All requests require an access token to be valid. The token is valid for a whole day and, unless you don’t have the access token or it expired, you should use this request to get a valid token:
- POST /token/¶
Return the access token. Most of the other requests require a valid token; a token will be valid for a whole day and you should only request a token when you either don’t have one or you receive a status 400.
Example request:
{ "username": "myUsername", "password": "myPassword" }Success (200):
HTTP/1.1 200 OK Content-Type: application/json { "status": "OK", "token": "access_token" }
Status Codes: - 200 – Success
- 401 – Wrong password (InvalidPasswordException)
- 404 – User does not exist (UserDoesNotExistException)
Users¶
- POST /user/¶
Create a new user.
Example request
{ "username": "username", "full_name": "I'm a person", "password": "MyPassword!" }Success (200):
HTTP/1.1 200 OK Content-Type: application/json { "status": "OK" }
Status Codes: - 200 – Success
- 406 – Invalid characters in username (InvalidUsernameException)
- 409 – Username already exists (UsernameAlreadyExistsException)
- PUT /user/¶
Authenticated request
Update user information. Only the fields send with be changed.
Example request
Change everything:
{ "full_name": "My New Full Name", "password": "newPassword" }Change only the user password:
{ "password": "newPassowrd" }Succcess (200):
HTTP/1.1 200 OK Content-Type: application/json { "status": "OK" }
Request Headers: - Authorization – Token received in /token/
Status Codes: - 200 – Success
- 400 – Request not in JSON format (RequestMustBeJSONException)
- 404 – User not found (via token) (UserNotFoundException)
- 412 – Authorization required (AuthorizationRequiredException)
- DELETE /user/¶
Authenticated request Delete a user.
Success (200):
HTTP/1.1 200 OK Content-Type: application/json { "status": "OK" }
Status Codes: - 200 – Success
- 404 – User not found (via token) (UserNotFoundException)
- 412 – Authorization required (AuthorizationRequiredException)