fukamachi / dexador

A fast HTTP client for Common Lisp
http://ultra.wikia.com/wiki/Dexador
377 stars 42 forks source link

Correct syntax for accessing Request Tracker rest api via token auth. #155

Closed aykaramba closed 1 year ago

aykaramba commented 1 year ago

I am trying to access my Request Tracker ticketing systems rest api interface with Dexador. I have created a token and I can successfully access the interface with curl as follows:

curl -H 'Authorization: token 1234-mytokenhere' 'http://10.10.10.10:8000/REST/2.0/queues/all'

When I try to use Dexador to do the same thing, I cannot authenticate. Code:

(dex:get "http://10.10.10.10:8000/REST/2.0/queues/all"
                  :basic-auth '("root" .  "1234-mytokenhere") :verbose t)

The debugger returns the following authentication error:

An HTTP request to "http://10.7.100.50:8000/REST/2.0/queues/all" returned 401 unauthorized.

{"message":"Unauthorized"}
   [Condition of type DEXADOR.ERROR:HTTP-REQUEST-UNAUTHORIZED]

The request tracker documentation is here: https://docs.bestpractical.com/rt/5.0.0/RT/REST2.html#Authentication just for reference, I don't expect anyone to read it.

The web interface does not accept the token as a password and I would like to just use the token method for authentication just like in the curl example which suggests the username is not actually required. What might be the correct Dexador syntax to send over the correct authentication arguments when trying to use a token?

fukamachi commented 1 year ago

You can use :headers to specify an Authorization header similarly to the cURL's example you wrote.

aykaramba commented 1 year ago

That worked! The syntax for a token based auth is:

(dex:get "http://10.10.10.10:8000/REST/2.0/queues/all"
                  :headers '( ("authorization" . "token 123-mytoken-456") ) 
                  :verbose t)

Thank you kindly!