Only username 'admin' can call API

Luke Crooks7 years ago

I am using basic authentication with the API, with the admin user/pass this works fine. I have created another user with the same 'admin' permissions and no results are returned from the api (and the logs don't show any declines) if I use the same code with the original admin user (and new password) it works perfectly.

Can anyone suggest why this might be? I can't see anything related to API access in the documentation?

Anton Tananaev7 years ago

API can't return no result. There's always HTTP response. You need to check what exactly comes in the response (code, headers and body).

Luke Crooks7 years ago

It returns a 200 response with an empty array.

Anton Tananaev7 years ago

Empty array is NOT the same as no result.

Luke Crooks7 years ago

OK, well it returns an empty array when not using the original admin user, as opposed to a new user with admin permissions, do I need to do anything else to mark certain devices within scope of this new user?

Anton Tananaev7 years ago

If you want to see devices of course you need to link those devices to your user.

Luke Crooks7 years ago

So if the 'admin' user has added device 'Bob' with unique id '123456' if the user 'api' wants to also see 'Bob' in the devices screen, how do I allow this? If I go to add another device to user 'api' called Bob with the same unique id '123456' the frontend throws a database exception...

ERROR: duplicate key value violates unique constraint "uk_device_uniqueid"
  Detail: Key (uniqueid)=(123456) already exists. - PSQLException (... < QueryBuilder:477 < DataManager:448 < BaseObjectManager:87 < ...)

So I am assuming devices are unique to each server instance of traccar, so how do I link one device to multiple users?

Luke Crooks7 years ago

Found it via the settings -> users then hovered over all the buttons to reveal a devices button which I could then share.