Version 5.3 API Tokens

timmcmic2 years ago

Hello everyone...

We have been using Traccar for quite sometime - and have had users with API tokens for our systems. These tokens were created in the previous web interface.

We have recently installed a brand new 5.3 installation and now our tokens are expiring (which is to be expected) every 7 days.

We need to obtain longer term tokens for these other systems we work with - but quite frankly we're not API type users.

Does anyone have pre-made code that we might try to recycle to do this? Will creating tokens that last longer than 7 days come back to the web interface for those of us that have partners but are not code savy?

Anton Tananaev2 years ago

We don't have any UI yet for selecting expiration time.

pling2 years ago

Will there be any way to set the expiration time for token in the config file ?

timmcmic2 years ago

That would be a nice middle around. We have some fixed workstations that display locations on televisions. The tokens we used to request in the gui worked fine. The tokens we request in the gui work fine today except you have to redo them every 7 days. It makes it harder for fixed
Applications

I tried going through the api guide but could not locate tokens under sessions - but then this is not my area of expertise.

Anton Tananaev2 years ago
timmcmic2 years ago

Anton...

I downloaded and installed 5.4 today. On the individual user object I selected the user and on the preferences I set a expiration time under the token expiration date of 3 years.

I then clicked the arrow to log in as that user account, and then on account I clicked the generate token button.

When I base 64 decode the token it still shows a 7 day expiration period.

I tried reviewing the code - am I not using this correctly.

Anton Tananaev2 years ago

Just tested. It's working correctly for me.

timmcmic2 years ago

Maybe you can tell me what I'm doing wrong.

Here are the screen shots.

https://fortmillems-my.sharepoint.com/:f:/g/personal/tmcmichael_fortmillems_org/Eksl4uyyWpZDt_wPdc4k2PIBalWZpgl_G9grtyAWPy5KuQ?e=cRgtVt

This is the token.

RzBFAiEA8OKgxAu9JrOZrT4XsSqBszIpwgj_LfBnTEsFLdSRy6ECIHjO48l7Gp1zjH0_VKNvevBRMGTBnxwN2uAoe0lizndReyJ1Ijo3LCJlIjoiMjAyMi0xMC0xM1QxNDoyMTo0OS40ODArMDA6MDAifQ

I appreciate you looking at it - we've had our displays for ambulance tracking offline for sometime.

Anton Tananaev2 years ago

This is NOT 5.4. Are you sure you cleared your browser cache?

timmcmic2 years ago

Interesting - I did not know that was required. I just updated, reconnected to my sql, and then verified in the server log that 5.4 was displayed.

Anton Tananaev2 years ago

That was always required. And it's not something specific to Traccar. In general your browser caches websites.