Authentication

As mentioned on the Introduction page, if an endpoint requires authentication, you have to pass the Authorization JSON header in your request with the token. You can get that token from the /login endpoint.

Endpoints

* /login [POST]

The /login endpoint is used to authenticate a user by verifying the provided username and password. Upon successful authentication, it returns a token that can be used to access other endpoints that require authorization.

Request Example

Method: POST

Header
{
    "Content-Type": "application/json"
}
Body
{
    "username": "string",
    "password": "string"
}

Return Example

200 OK
{
    "token": "string"
}

400 Bad Request
{
    "error": "Invalid login data"
}

401 Unauthorized
{
    "error": "Invalid username or password"
}

This error can be returned in two cases: when there is no row for the username in the database, or when the (decrypted) password hash doesn't match the entered password.


500 Internal Server Error
{
    "error": "Database error"
}

This gets returned if the database can't be accessed.


500 Internal Server Error
{
    "error": "Failed to generate token"
}

This gets returned if the token generation process fails.

Last updated