Obtaining a token
Before sending requests to the system, you need to obtain a token.
A token is a unique string that confirms you are an authorized user of the system.
Without a token, the server will not allow you to access data or create and edit tasks.
How it works
1. You request a token once
2. From that moment, all your requests to the server include this token
3. The server verifies the token and grants access to the API
How to get a token
Method
GET
Request address
To get the data, use the address: https://tasks.<server_address>/backend/public/getToken
Example request (JavaScript fetch):
fetch("https://tasks.pilot-gps.ru/backend/public/getToken?_dc=1597911308273", {
method: "GET",
headers: { "accept": "*/*" },
credentials: "include"
})
.then(response => response.json())
.then(data => {
console.log("Your token:", data.token);
});
|
Response
{"token": "CtrsOKz3NykfxWlyboPlq3LGNpPrWsCtIymrKq0G"}
|
Your unique token is stored in data.token.
How to use the token
Method 1: In AJAX Headers (for all requests)
If you are using JavaScript and making multiple requests via fetch or $.ajax:
$.ajaxSetup({
headers: { "X-CSRF-TOKEN": token } // token is the string you received
});
|
Set this once, and all subsequent requests will automatically include the token.
Method 2: As a Hidden Field in HTML Forms
If you are submitting forms via POST/PUT/DELETE:
<input type="hidden" name="_token" value="CtrsOKz3NykfxWlyboPlq3LGNpPrWsCtIymrKq0G">
|
This works for standard HTML forms. Note: you need to include the token in each form individually.