Skip to content

Creating a Strava API Application & authentication

Samantha Csik edited this page Sep 3, 2024 · 3 revisions

If you're looking to work with your own Strava data, the most challenging part (in my experience) was just getting my account set up correctly. You should start by checking out the Strava API documentation. If you need a concrete example, here are the exact steps I followed:

  1. Log into Strava (or create an account if you don't already have one)
  2. Click on your profile icon (top right corner) > Settings > My API Application (from the left-hand menu)
  3. Provide Strava some information about your app (NOTE: I don't totally know what I'm doing here, but the information below worked for me):
    1. Give your application a name (this can be anything, but I called mine SamsHeatmaps)

    2. Select a category (since I wanted to create a heatmap, I chose Visualizer from the dropdown menu)

    3. Provide a website URL for your app (I included the link to this GitHub repo)

    4. Give it an Application Description (my description is, Learning to use the rStrava package and hopefully create my own heatmaps)

    5. Provide an Authorized Callback Domain (I wrote localhost)

Once you save your API Application information, you'll be provided with both a Client Secret and an Access Token, both of which you need in order to scrape your data. Using the {rStrava} package makes it pretty easy to do so. The first step is to create a "Strava Token", using the following code:

# save your app name, client ID, and secret (NOTE: I've saved these vars to a separate `keys.R` file, which I source in and add to my `.gitignore`) ----
app_name <- "<APP NAME>"
app_client_id <- "<CLIENT ID>"
app_secret <- "<CLIENT SECRET>"

# use them for account authentication / to create your token ----
my_token <- httr::config(token = strava_oauth(app_name, app_client_id, app_secret,
                                              app_scope = "activity:read_all"))

A browser window should open asking you to authorize Strava to access your data. Once you agree, it'll return a message in the browser, Authentication complete. Please close this page and return to R. This means things are working!

You're now ready to retrieve, wrangle, and plot your data! For a minimal example, check out my the next wiki article, Getting your Strava activities, or dive into scrape_strava.qmd file to see my full data cleaning pipeline.

Clone this wiki locally