Search API Connector Documentation

Print

Import Polar Flow Data into Sheets

In this guide, we’ll walk through how to import Polar activity data directly into Google Sheets, using the API Connector add-on for Sheets.

Polar API’s OAuth2 requirements are incompatible with API Connector’s OAuth2 connection manager (because they require that the client ID/secret is passed as an auth header instead of in the request body). So we will get our token through some “regular” API requests instead.

This is a rather inconvenient API for reporting because it uses a “transaction” model that requires multiple steps to retrieve data, as they describe here:
polar-img0

Further, you can only query new data, not historical data already stored in the Polar Flow service. So this won’t be the easiest API to work with, but the instructions below attempt to de-mystify the process as much as possible.

Contents

Before You Begin

Click here to install the API Connector add-on from the Google Marketplace.

Part 1: Create a Polar App

  1. Navigate to https://admin.polaraccesslink.com/ and log in using your Polar Flow credentials
  2. Once you’re logged in, click on + CREATE A CLIENT
    polar-img1
  3. You’ll be prompted to fill out organization information. You can put your personal information if you are not representing a company.
    polar-img2
  4. Next, fill out the Application Information. You can set the Callback address to anything, but https://www.google.com is good as it’s easy to access and doesn’t redirect.
    polar-img3
  5. The next screen (“Check Information”) shows you what you entered previously. Review and click Confirm.
  6. You’ll now see your Client ID and Client Secret. Note these down as they won’t be shown again (though if you lose them, you can simply regenerate new ones, you don’t need to go through the above process again).
    polar-img4

Part 2: Get Your Auth Code

  1. Take the Client ID you just got and substitute it into this URL:
    https://flow.polar.com/oauth2/authorization?response_type=code&scope=accesslink.read_all&client_id=YOUR_CLIENT_ID
  2. Paste that entire URL into a web browser
    polar-img5
  3. You will see a screen prompting you to log in and accept whatever permissions you selected while creating your app. Click Confirm.
    polar-img6

  4. You’ll now be sent to the site you sent as your callback URL (google.com in our example). On this screen you’ll see a URL in your URL bar. We’re looking for the value in the ‘code’ parameter, so grab that and keep it safe.
    polar-img7
  5. One last step: since we need to send Polar encoded credentials in a header, let’s do that now. Type your credentials into this form, using the format client_id:client_secret. Your encoded credentials will appear underneath.

    The encoding script runs in your browser, and none of your credentials are seen or stored by this site.
 

 

 

Part 3: Get Your Access Token

  1. Choose the POST method and enter this request URL for an access token
    https://polarremote.com/v2/oauth2/token
  2. Under Headers, enter Key = Authorization, Value = Basic ENCODED_CREDENTIALS
  3. In the POST body, enter the following, substituting in the code you got earlier.
    { "grant_type":"authorization_code",
    "code":"c3411111111111111111111111" }
  4. Name your request and click Run . The whole thing should look like this:
    polar-img8

Congrats, you finally have your access token. This is what we’ll use for getting data. Note your x_user_id, too, as we’ll need that soon.

Part 4: Register User

You can see a list of available endpoints and metrics in their docs, but again it’s not very straightforward. To get data we first have to “register” ourselves. To register yourself, set up a request like this:

Method: POST

URL: https://www.polaraccesslink.com/v3/users

Headers:
Key = Authorization, Value = Bearer YOUR_TOKEN
Key = Accept, Value = application/json
Key = Content-Type, Value = application/json

Request body: (substitute in the x_user_id value you received along with your token)
{“member-id":48660157}

polar-img9

Part 5: Get User Data

All right, we’re registered! But we still have to “initiate” transactions for each data point we want to pull. Initiate the transaction like this:

Method: POST
URL: https://www.polaraccesslink.com/v3/users/{user_id}/exercise-transactions
Headers:
Key = Authorization, Value = Bearer YOUR_TOKEN
Key = Accept, Value = application/json
Request body:
{“user-id”:48660157}

polar-img10


When you send this request, the API will respond with a series of URLs. Plug each URL into API Connector as a GET request to run and retrieve the data contained within.
polar-img11

If you’ve made it this far, I would love to know if this worked for you 😀

Previous Import Zoho CRM Data to Google Sheets

Leave a Comment

Table of Contents