I see the share device feature which creates a url like
http://traccar.ws:8082?token=Rz...
but what I need to do is generate the token programatically from outside the Traccar Server app.
Is this possible?
Thanks,
kev
It should be possible to generate a token programatically. Web app uses the same API.
Anton, is there any further info to generate the token specific to loading the Device in the app?
The information about Access Token on https://www.traccar.org/traccar-api/ is somewhat brief and uninformative. I have tried to send the get request from Postman to http://traccar.ws:8082/api/session?token=USER_TOKEN
, using the bearer header as per other working requests, but get a 400 Bad Request response and the following;
-75 - NegativeArraySizeException (CryptoManager:72 < TokenManager:77 < LoginService:81 < SessionResource:81 < ...)
I have scoured the resources and cannot find any reference to creating the token that links directly to the device as per the share device example.
Thanks,
Kev
It seems like the token is invalid.
I use the same token generated in the servers Settings->Preferences->Token option and it works fine as a Bearer token in the numerous API calls I make to create and edit Groups, Users and Devices.
When I replace the string "USER_TOKEN" with this token the API call works, but delivers back the exact same JSON as when I do a GET request to /session with the Bearer Authorisation. What is the point of this?
When you say "Web app uses the same API." What is the syntax of this API call? I cannot see any reference in the API documentation for /session to specify a device, nor anything in /devices to generate a token.
I am no closer to generating a Token to use for a URL link to an individual device...
The easiest option is to open the official web app, share a device and look at what API call the app is making.
How do you look at what API call is being made by the server app?
Browser console.
I have an external PHP process that runs every 5 mins between 6pm and 6am to detect out of hours activities on specific devices. Basically I look for ignitionOn and ignitionOff events and extract the distance travelled from the attributes to determine if it an event to report by email.
The email has a google maps link but I would prefer if there was a link that could take the customer into the server app selecting the particular device so it could be viewed in real time.
Is this at all possible or something that could be done in a future release?
Thanks,
kev