API Authentication

All the endpoints of the CamDirector are protected by JWT authentication. This means that you need to supply an authentication token to each HTTP request. The following steps will explain how to authenticate with the API and supply the JWT token to you next request. The tutorial makes use of Postman v11.29.3 for sending HTTP requests. Postman has an interactive UI for sending requests and simplifies the authentication process.


Base url: http://{ip}/api

Action

HTTP Method

Endpoint

Authentication

POST

/manager/auth

Turning into live mode

POST

/on

Turning into edit mode

POST

/off

Switch to scenario

POST

/switch/scenario/{id}

Switch to preset

POST

/switch/preset/{id}

Switch to camera output

POST

/switch/camera/{id}

1. Login with credentials

To retrieve a JWT token you need to make a request to the authentication endpoint.

The Authorization type is a Bearer Token. This is a HTTP POST request and requires a JSON body with the username and password fields of the CamDirector. In the response you will receive your JWT token in the body.

In this case "admin", and "admin"  (do not forget the comma).

Open image-20241210-103426.png

After pressing the send button, you will receive a token. And the "200 OK"

And everyone who was logged in via the WebGUI will be logged out.

Open tab Authentication. You can open the token window.



The new token appears in the body window under. It needs to be copied into the token window.

2. Using your JWT token

The token should be supplied in the request header as a Bearer Token. The lifetime of the token is supplied in seconds and is 3600, which means the token is valid for one hour. Only one user can be authenticated at the same time, so when another client logs in, other tokens become invalid and you receive "401 Unauthorized". And you have to generate a new one.

3. In practice 


If you want to turn off "LIVE," you can do so with:

POST http://172.26.41.20/api/off.

After pressing "SEND," you will receive this response.

If someone opens the WebGUI, the token will be invalid and you received "401 Unauthorized"

Open image-20241210-110207.png