1 API Auth
kolaente edited this page 2018-01-12 16:29:10 +01:00

[API] Authentification

To authenticate a user, you will need to send a Authorization: Bearer <YOUR-TOKEN> -Header with every request where authetification is needed. The api will respond with a 401 - Unauthorized header when the token is invalid or not send.

POST /login

Returns a JWT-token to authenticate future requests where needed.

Payload

Expects a username and a password, either as form values or JSON object. When sending as JSON object, you need to specify the Content-Type: application/json;charset=utf-8 -Header.

Response

200 Username and password are valid. Returns a JWT token.
400 Either no username or password provided.
401 Wrong username or password.
500 A server error occured.

Example

Request via JSON object:

curl \
-X POST \
-H 'Content-Type: application/json;charset=utf-8' \
-d '{"username":"user","password":"1234"}' \
http://localhost:8082/api/v1/login

Or directly via form values:

curl \
-X POST \
-d username=user \
-d password=1234 \
http://localhost:8082/api/v1/login

Result:

{
  "token": "<YOUR-TOKEN>"
}