I want to share my code about how to authenticate to the Remember the Milk API from Google Apps Script

Over on the Google+ Remember the Milk community, I recently saw a question about how to authenticate to the Remember the Milk API from Google Apps Script.

First thing I thought was… Awesome, I can answer that. I have an example in an old Google Spreadsheet I played around with a year ago. So I went digging around in my old projects, found the code, and of course immediately realized that the code as written wasn’t really something I could share or something that would be helpful. And then I realized that I didn’t really understand the code well enough anymore to be able to give a useful short explanation of the steps involved.

So why not take a crack at writing about the code here – going through it and re-explaining it to myself. And then if that turns out well then maybe I’ll share the post back with the guy who asked the question.

Of course then I realized… I don’t have time to do that. So I thought maybe I’ll just start writing about the part that I do have time for, and try to improve it when I can. You know – the agile approach. 🙂

Sneak peek: Some of the high points are…

You need an API key and a shared secret. You need the RTM API authentication URL. You need the RTM API REST URL.

You need to know a little about parsing a JSON response.

You need a function which gets the “frob” (and need to know that the “get frob” method is called “rtm.auth.getFrob”).

You need a utility function which will convert some bytes to text for the hash values you are using with the API.

You need to construct an API signature string which you’ll send in the payload for the REST method along with the API key, shared secret, data format (JSON), frob, and method name.

You need to know how to retrieve the authentication token by accessing this object in the JSON response:

var token = parsedJSON['rsp']['auth']['token'];

And that’s as far as I got with this post for now.