public
Created

Runkeeper API startup guide: I ran into some hitches with the Runkeeper API while building a plugin to hook it to Slogger, so I wrote a quick guide to accompany the plugin itself.

  • Download Gist
Runkeeper_API_startup.md
Markdown

Runkeeper API startup

Begin with the Runkeeper Registration/Authorization page for general instructions to get started. This page points to the Application Portal you can use to establish your application. You'll obtain client_id and client_secret by registering a personal application in that portal.

Then obtain code by submitting a request to https://runkeeper.com/apps/authorize with the following parameters directly from the Runkeeper instructions:

  • client_id: The unique identifier that your application received upon registration
  • code: code
  • redirect_uri: The page on your site where the Health Graph API should redirect the user after accepting or denying the access request

I found the easiest way to make this request for my purposes was simply to cobble it into a URL and paste directly into the browser location bar: https://runkeeper.com/apps/authorize?response_type=code&client_id=[MY_CLIENT_ID]&redirect_uri=http%3A%2F%2F[MY_URL.COM]

Replace MY_CLIENT_ID and MY_URL.COM with your values. The URL can be localhost or a domain you control; the request will redirect to it with its returned code value. You'll need to re-use the same value in the form below to obtain a user API token.

Now you need a user token; you'll plug this in to any request for data from the Runkeeper API. There are elegant ways to do this, and then there's this way: A quick HTML form that makes the request for the token. Seriously, I tried all kinds of curl permutations and couldn't get them to work, so I did it this way. It worked. Fill in the values, submit, and get a token back. (I did this all right in a TextMate preview window.)

<html>
<body>
  <h1>runkeeper API token obtainer</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://[MY_URL.COM]"><br>    
    <input type="submit">

</form>
</body> 
</html>

Save the returned token to use in your API calls, and you're good to go.

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.