Thursday, July 26, 2012

Google Latitude OAuth Bridge

As part of my project to use Indigo 5 (http://www.perceptiveautomation.com/indigo/index.html) to automate my house (and also remind me when I am forgetful of doing things like closing the garage door when I leave the house...), I decided to integrate Google Latitude into the server so that a variable "isAtHome" would be exposed and various triggers can decide on what to do (e.g. emailing me when nobody's at home but there's activity detected in the house).

Anyways, it turned out to be a bit of a difficult task since the Google Latitude API requires OAuth 2.0 with tokens that live for an hour. That wouldn't really work with something like Indigo which would have required me to store a whole bunch of stuff (client ids, client secrets, tokens, refresher tokens) and execute multiple round-trips against Google auth servers before you can get your location securely.

Well, decided that I might as well do what I do best and whipped up a Google App Engine + Play Framework + Siena + bootstrap combo that would allow me to generate a permanent URL for the JSON query.

After about 2 hours, http://latitudebridge.appspot.com is up. :)

Twitter's Bootstrap project is awesome!

Basically, you do the OAuth once and it generates a unique URL for you to query your current position. Just like the old days. :)

Next up, get the applescript written so that it can do a curl and figure out the rest.

No comments:

Post a Comment