ni-c / heimcontrol.js

Home-Automation with node.js and Raspberry PI
MIT License
1.41k stars 297 forks source link

Heimcontroljs API #34

Closed JorisM closed 10 years ago

JorisM commented 10 years ago

I want to connect to heimcontrol.js through an API, so I can make an iPhone/Android.

I got an authentication system working with an token key quite easily. I'm stuck however at sending requests with the token to the plugins with socket.io.

To me it seems like socket.io requires a cookie to send requests to the plugins. Do you have an idea how to work around this? So I can just use the token to send requests to the plugins?

I set up an experimental branch, here is my auth token implementation so far: https://github.com/JorisM/heimcontrol.js/commit/9edf819f7c295072fde5ffd2a130f045df99bd8e Thanks

ni-c commented 10 years ago

Hey,

you have to change the authorization function in heimcontrol.js:61.

This is where the cookie authorization happens. You replace or extend this with your token authorization and return true in the callback-function if your token is valid.

https://github.com/JorisM/heimcontrol.js/blob/9edf819f7c295072fde5ffd2a130f045df99bd8e/heimcontrol.js#L61

JorisM commented 10 years ago

Thanks! I had a wrong approach, I wanted the Server to emit the socketio event. I finally started digging into websockets and now have my android app connecting with a socket. Still WIP but it's getting there.