HOME › Forums › Gateways › Raspberry Pi › trying to authenticate
-
AuthorPosts
-
AnonymousInactiveSeptember 6, 2013 at 12:12 pmPost count: 19
Hi guys,
I recently got my raspberry pi and zigbee dongle (USB-CID). I was thinking of writing a small application for it and was trying out the http/xml API interface of the dongle. The first thing I tried was to authenticate. But unfortunately, this is already where I got stuck. No matter what I do, the thing always replies with:
{“object”:””, “method”:””,”session”:”dd7fed82-cb35-4ff2-b8ac-b3c2bf4336b6″,”error”:”Not Authenticated”}
I included the xml package as described in the documentation in the content of the http request. What am I doing wrong?AnonymousInactiveSeptember 6, 2013 at 3:14 pmPost count: 259Hi,
Are you sending the hash of the password in the Sys_Authenticate packet?
AnonymousInactiveSeptember 7, 2013 at 6:34 pmPost count: 19yep, I am.
Also, if the hash is incorrect, shouldn’t I get an xml result back instead of a json stream?AnonymousInactiveSeptember 7, 2013 at 7:14 pmPost count: 259Here is the Packet you should send. Notice the password “Smartenit” has been hashed (SHA1)
ZBP_System
Sys_Authenticate09cbef6f2f30e9bf9a202c53142295478786d5f3
25784
Response:
ZBP_System
Sys_Authenticate2
25784
5e9f7400-2bc3-4318-b869-ac8166874b1dAnonymousInactiveSeptember 8, 2013 at 2:49 pmPost count: 19I just tried it again with fiddler, just copied your xml element and used that as request body. Still getting a json element back that says:
{“object”:””, “method”:””,”session”:”27af8723-64a2-4945-8ab6-1ee7c19d4879″,”error”:”Not Authenticated”}�AnonymousInactiveSeptember 8, 2013 at 4:20 pmPost count: 259Oh i forgot to mention that every xml packet must end with a null byte at the end. Try that and let me know.
AnonymousInactiveSeptember 9, 2013 at 7:08 amPost count: 19Ok. That might explain things. I’ll have to put something together for that first. Thanks.
I suppose this means everything you send to the api has to be ended with a null byte?AnonymousInactiveSeptember 9, 2013 at 7:29 amPost count: 259Yes the Gateway discards packets that don’t end with null bytes.
AnonymousInactiveSeptember 9, 2013 at 9:38 amPost count: 19I added a null terminator to the string (added a 0 char at the end, in C++). Still getting the same json response: Not authenticated.
AnonymousInactiveSeptember 9, 2013 at 5:31 pmPost count: 259Hi,
Are you sending the XML after creating a TCP socket connection to port 50333 ? I think you are using HTTP GET to get that JSON response.
AnonymousInactiveSeptember 10, 2013 at 12:49 pmPost count: 19Hi,
I’m indeed using a HTTP GET request with the xml as content. In the case of the self written app, I indeed first create a TCP connection on port 50333. This works very well on other ports (to get a resonse from other services). I am also using fiddler as a debug tool so I can send http requests to the device without first having to code. For that, I just go to the composer tab, use the address http://[ip address of raspberry]:50333 and put the xml in the ‘request body’AnonymousInactiveSeptember 10, 2013 at 1:17 pmPost count: 19Also, on top of each page in the class reference, there is a reference to a C header file. Where can I find those headers? (did a search on my raspberry but can’t seem to find them). Perhaps that’s an easier approach than the whole HTTP communication thing, which doesn’t seem to work…
AnonymousInactiveSeptember 10, 2013 at 2:35 pmPost count: 19I’v been doing some tests with the harmony gateway app. This does appear to be able to connect. I put a packet sniffer in between so I could see what exactly is being sent. So first off, you are right about the 0 char terminator, which I can’t simulate in fiddler.
Second, I noticed that you are sending 224 data bytes, so that packet is using unix line terminators and puts a couple of spaces in front of the xml elements. I am currently sending 204 bytes as I removed all the spaces and newlines from the xml string. Other than that, I don’t immediately see much of a difference between the requests. Do you know of something else I can perhaps try?AnonymousInactiveSeptember 10, 2013 at 3:29 pmPost count: 259You have to connect to the TCP Socket, http get is not supported, the gateway will always send that json response if you use http get.
AnonymousInactiveSeptember 10, 2013 at 4:37 pmPost count: 19ok, so I have to program against the raw sockets instead of through http. Let me try that.
Also, I noticed that sometimes the harmony web application also fails to connect… -
AuthorPosts
- You must be logged in to reply to this topic.