Page 1 of 1

Authenticating problems with API

Posted: Mon May 15, 2017 10:01 pm
by csgnyc
I have been through these boards, and I think I'm following instructions.

If I enter

Code: Select all

curl -c cookies.txt --compressed -i -H "Content-Type: application/json" -H "Accept: application/json" -X POST -d '{"method": "auth.login", "params": ["deluge"], \"id\": 1}' http://192.168.1.10:8112/json
I get a response that includes session_id.

If I then enter

Code: Select all

curl -b cookies.txt --compressed -i -H "Content-Type: application/json" -H "Accept: application/json" -X POST -d '{"method": "web.connected", "params": [], "id": 1}' http://192.168.1.10:8112/json
I get a "not authenticated" message. I have tried other commands and get the same error.

My web interface for deluge is at 192.168.1.10:8112, but I note that 192.168.1.10:8112/json is an empty page. I'm on a synology if that makes a difference.

Re: Authenticating problems with API

Posted: Mon May 15, 2017 10:28 pm
by Cas
Please provide actual response

Re: Authenticating problems with API

Posted: Mon May 15, 2017 11:25 pm
by csgnyc
This is the response:

Code: Select all

HTTP/1.1 200 OK
Transfer-Encoding: chunked
Date: Mon, 15 May 2017 23:24:44 GMT
Content-Encoding: gzip
Content-Type: application/x-json
Server: TwistedWeb/16.6.0

{\"id\": 1, \"result\": null, \"error\": {\"message\": \"Not authenticated\", \"code\": 1}}

Re: Authenticating problems with API

Posted: Tue May 16, 2017 9:52 am
by csgnyc
I figured out a fix -- I specified where to store the cookies.txt file in both codes.

So, for the first code I used

Code: Select all

curl -c /tmp/cookies.txt --compressed -i -H "Content-Type: application/json" -H "Accept: application/json" -X POST -d '{"method": "auth.login", "params": ["deluge"], \"id\": 1}' http://192.168.1.10:8112/json
, and for the second code I used

Code: Select all

curl -b /tmp/cookies.txt --compressed -i -H "Content-Type: application/json" -H "Accept: application/json" -X POST -d '{"method": "web.connected", "params": [], "id": 1}' http://192.168.1.10:8112/json
, and everything seems to work.

Re: Authenticating problems with API

Posted: Tue May 16, 2017 10:00 am
by Cas
Glad you sorted it :)