If you know and use DayOne for journaling, you likely also know Brett Terpstra's great little Ruby application Slogger. It runs from the command line and logs all sorts of social media tidbits like your tweets, articles you publish (via your blog's RSS feed) or FourSquare checkins in DayOne.
Installing Slogger is pretty straight forward, but you need to have Xcode and the Command Line Tools of Xcode installed as a prerequisite. Something I oversaw which led to some embarrassing tweet which Brett had to answer.
Getting Slogger to authenticate with and collect from social media services like Twitter or Instagram is surprisingly easy. However, getting it hooked up with RunKeeper to log your workouts requires a little more fiddling.
Registering with the HealthGraph API
First you need to register your "application" with the RunKeeper API which is called HealthGraph. The whole process is a little confusing as you actually need to go to the Application Portal of RunKeeper to do that.
Once you logged in with your regular RunKeeper account you need to enter a few simple bits to generate a Client ID and Client Secret string.
Hacking URL Requests
From here it gets a little messy since neither RunKeeper nor Slogger offer a simple way to generate the token you need for the Slogger configuration to work. Without this Gist from Alan Schussmann it would have been impossible for me to get it to work myself.
First thing we need from the HealthGraph API is a code we can then use to generate a Token. This code is returned by the API once we make an authorisation request to
https://runkeeper.com/apps/authorize with the Client ID we got when we registered our application.
Enter the following URL into your browser by replacing the '[CLIENT_ID]' placeholder with your real Client ID and fire it off:
There is likely an error message displayed in your browser window due to 'localhost' being unreachable. However, the URL parameter in redirected URL displayed your browser's location field will contain the code we are after.
Building A Little Web Form
We are not done yet since what we have is a Code and not a Token. Grab a text editor such as TextEdit and copy and paste this simple HTML form into it (again kudos to Alan Schlussmann to work this out):
<html> <body> <h1>Get that damn RunKeeper API Token</h1> <p>Insert values for your API key below, and submit. This form will return a token that can be used for RunKeeper API requests.</p> <form action="https://runkeeper.com/apps/token" method="POST" enctype="application/x-www-form-urlencoded"> grant_type <input type="text" name="grant_type" value="authorization_code"><br> code <input type="text" name="code" value=""><br> client_id <input type="text" name="client_id" value=""><br> client_secret <input type="text" name="client_secret" value=""><br> redirect_uri <input type="text" name="redirect_uri" value="http://localhost"><br> <input type="submit"> </form> </body> </html>
Save it as an HTML file on your Desktop and drag and drop it from there into your browser window. It may look a little odd, but it will work, trust me.
Enter the Client ID and Client Secret when registering the application with the HealthGraph API in the first step as well as the Code you got from fiddling with that URL Requests in the last step in this form displayed and press submit.
If all went well you should get a API Token in return which you can now enter into the Slogger configuration file and happily collect workout data in your DayOne journal.