Skip to content

Login API

The login route is the endpoint to perform the login authentication process. After the login is performed the client gets a session cookie.

After the login process is done, the client has to send the session cookie with every HTTP request until logging out. (the cookie expires after one hour)

The endpoint can be accessed at <address>:<port>/login.

POST

The POST method is used to perform the login. It is the only request-type supported by the login route.

Access

Python requests:

requests.request("POST", "http://<address>:<port>/login", json=<arguments>, headers={"Content-Type": "application/json"})

Unix curl:

curl -X POST -d '<arguments>' -H "Content-Type: application/json" http://<address>:<port>/login

JavaScript fetch:

fetch("http://<address>:<port>/login", {method: "POST", headers: {"Content-Type": "application/json"}, body: JSON.stringify(<arguments>)})

Replace <address> and <port> with your respective setup. Replace <arguments> with the arguments listed below.

Arguments

Argument Type Necessity Example Description
user_mail string required John Doe The e-mail address of the user.
user_pass string required testPW The user password as defined in the registration of the user account.

Arguments are constructed as dictionaries or JSON objects.

Response

The response is a dictionary or JSON object. If authentication process succeeds a success message with a session cookie is returned with HTTP status 200.

{
    "message": "Welcome John Doe!",
    "user_id": 3,
    "user_mail": "johnDoe@example.com",
    "user_name": "John Doe",
    "user_role_name": "User",
    "user_role_value": 3
}

A required argument was not sent.

{
    "message": {
        "argument": "Error Text"
    }
}

Password or username is incorrect.

{
    "message": "Incorrect user name or password"
}