The Hub is now in read-only mode as we make improvements to the Hub experience. More information is available here.
01-30-2023 11:48 AM - last edited on 07-06-2023 05:13 PM by LouB
I have written a javascript command with the help of Chat GPT3 (I am not a developer) but would love some community assistance here! I'm looking to import activity data from Strava into an Equals spreadsheet.
Can someone help me understand what I need to do to fix this? Any support is very appreciated!
Here's what I have:
const equals = require("equals");
const axios = require("axios");
const STRAVA_ACCESS_TOKEN = equals.getSecret("strava_api_key");
const STRAVA_ATHLETE_ID = equals.getSecret("strava_athlete_id");
const TABLE_NAME = "Activities";
const postData = async () => {
const resp = await axios({
method: "post",
url: `https://www.strava.com/api/v3/athletes/${STRAVA_ATHLETE_ID}/activities`,
headers: {
Authorization: `Bearer ${STRAVA_ACCESS_TOKEN}`
}
});
return resp.data;
};
const data = await postData();
equals.addHeaders(["Name", "Sport Type", "Elapsed Time", "Description", "Distance"]);
for(const record of data) {
equals.addRow([
record.name,
record.sport_type,
record.elapsed_time,
record.description,
record.distance
]);
}
Solved! Go to Solution.
01-31-2023 11:54 AM
The method should be "get" and not "post".
But more importantly, the access token is not the same as your API key. You actually should use the API key to fetch the access token. But explaining the whole OAuth2 flow here might be a bit of a stretch...
01-31-2023 11:54 AM
The method should be "get" and not "post".
But more importantly, the access token is not the same as your API key. You actually should use the API key to fetch the access token. But explaining the whole OAuth2 flow here might be a bit of a stretch...
01-30-2023 11:50 AM
Btw - I followed these steps to set up my API key: https://medium.com/@annthurium/getting-started-with-the-strava-api-a-tutorial-f3909496cd2d
Welcome to the Community - here is your guide to help you get started!