Use of token authentication

FdoHdez7 years ago

Hello.

I got valid token and trying to use it on a GET request by means of following curl command:

curl -X GET -H "Authorization: Token qFEG1TGVVjHDw4AHBMNqGcvQMRM7IoVA" -H "Accept: application/json" "http://181.143.52.195/api/positions"

However server is responding with error: ArrayIndexOutOfBoundsException

Am I doing an incorrect curl request?

Thanks in advanced.

abyss7 years ago

Token must be passed as url parameter to authorize (get session)

FdoHdez7 years ago

Hello abyss thanks for your reply.

I tried like this:

https://www.dropbox.com/s/7zao21ef6ejr89v/token-in-url.png?dl=0

But as you could see, now I'm getting a 401 unauthorized. Could you please help me in finding what is wrong?

abyss7 years ago

Firstly you have to get session via https://www.traccar.org/api-reference/#paths_session
Then you can use it (cookie JSESSIONID) in other API requests.

I solved it, copying the simple folder, create a folder called close and the line in the
ajax app.js ('GET', url + '/ api / session? token =' + token, function (user) {
change it to
ajax ('DELETE', url + '/ api / session? token =' + token, function (user) {
yourserver:port/close
and ready