krohling / ArduinoPusherClient

An Arduino interface to Pusher (pusherapp.com)
150 stars 61 forks source link

little info as to how to use private channels #3

Open michahell opened 12 years ago

michahell commented 12 years ago

Mostly concerning the auth_token. Where do we get it from? Is it the CSRF token spoken about here -> http://pusher.com/docs/client_api_guide/client_connect or is it just something we choose ourselves?

michahell commented 12 years ago

Never mind, i now understand that this is simply not possible without a server-side authorisation... really too bad. You can't 'just' send messages from arduino to whatever app you're making. Gets really cumbersome this way, but, let's see if it works.

michahell commented 12 years ago

Okay, i got my authentication working, that is, on my serverside (my own domain). However, Pusher won't accept arduino as authenticated client, as there seems to be something wrong with the JSON arduino sends. Screenshot here -> http://s14.postimage.org/4h460cqk1/arduino_wrong_JSON.png

This is my entire arduino sketch -> http://s14.postimage.org/f2o1ccwvl/arduino_sketch.png

This is the arduino sketch line where i authenticate:

client.subscribe("private-hitit", "def7cddb263b06e03ad1:52cd5f19949ac39039a206347baff007d6472464496190c23850cceaabbca382");

And the key is the one that this PHP library provided me with: https://github.com/squeeks/Pusher-PHP#private-channels

So, why is arduino not getting authenticated?

michahell commented 12 years ago

I have now got the authentication working for the HTML5 app i'm building, it can succesfully send client events. However, i needed to authenticate using JSONP using a PHPscript on my own domain. How can this be done in arduino? Or are there any plans to add this functionality to the library? otherwise, it's not possible to send client events!

chriswhong commented 12 years ago

It took some doing, but I finally got a successful authentication to a private channel from my Arduino. I had to trim down the libraries and add a couple of new functions, things seem to get loopy when dealing with very large strings.

I'd love some feedback... I am a n00b and this is probably very sloppy code.

http://www.charmcitynetworks.com/news/sending-pusher-client-events-from-an-arduino/

pbouchet commented 12 years ago

Nice one! I didn't know you could have two simultaneous sockets with the ethernet shields.

I'm using client-events with a Wifly module. These support multiplexed HTTP too, but require a specific firmware to do so. This specific firmware lacks other functionalities that I need though, so I can't use it.

Instead I do everything on the AVR, which allows me to make it work with only 1 TCP socket (however this means you have to put your secret key on the device, so there can be security issues with this approach).

My implementation is available here.

fsamir commented 12 years ago

+1 for for some better support for triggering events from Arduino (with or without private channels).

michahell commented 12 years ago

i'd like to bump this thread, until Pusher decides to do something about this :) (this is important! help out the IoT community so we can build awesome stuff for you to put on your showcases! How about an indoor hanging garden modular system which uses Pusher? Sound good? Well, i'm about to embark on such a project and i would love to use Pusher for it, but as it stands now... I don't think so!

pbouchet commented 12 years ago

@michahell What is it that prevents you from using it? What is your hardware setup? Are you using an Ethernet shield or something else?

michahell commented 12 years ago

Wait... This is not the actual thread i wanted to post a reaction on. I'm sorry about the reply, it was a bit ment towards the Pusher creators :p I had it bookmarked because it had to do with pusher ><. i'll remove it! But still, i'd love to see your implementation (currently your posted link breaks here). I had a similar hardware setup like you did (WiFi xBee + shield) and i'd love to be able to do the auth on AVR as well, that would solve the issue for me!

pbouchet commented 12 years ago

Whoops. Here is the correct URL: https://github.com/reaDIYmate/avr-libraries/blob/master/barebone/PusherClient.cpp