Skip to content

Instantly share code, notes, and snippets.

@alfianyusufabdullah
Created November 28, 2024 09:32
Show Gist options
  • Save alfianyusufabdullah/a653dbe58beeb062a8d3813f42fd6112 to your computer and use it in GitHub Desktop.
Save alfianyusufabdullah/a653dbe58beeb062a8d3813f42fd6112 to your computer and use it in GitHub Desktop.
function refreshAccessToken() {
const prop = PropertiesService.getScriptProperties()
const refreshToken = prop.getProperty("REFRESH_TOKEN");
const clientId = prop.getProperty("CLIENT_ID");
const clientSecret = prop.getProperty("CLIENT_SECRET");
const url = 'https://launchpad.37signals.com/authorization/token?type=refresh&refresh_token=' + encodeURIComponent(refreshToken) + '&client_id=' + encodeURIComponent(clientId) + '&client_secret=' + encodeURIComponent(clientSecret);
const options = {
method: 'post',
muteHttpExceptions: true
};
var response = UrlFetchApp.fetch(url, options);
Logger.log(response.getContentText());
}
function createNewCard() {
const prop = PropertiesService.getScriptProperties()
const accessToken = prop.getProperty("ACCESS_TOKEN");
const accountId = '5135326';
const projectId = '34426082';
const columnId = ``
const url = `https://3.basecampapi.com/${accountId}/buckets/${projectId}/card_tables/lists/${columnId}/cards.json`;
var payload = {
title: "Testing new Card",
content: "Content new card",
due_on: "2025-01-01"
};
var options = {
method: 'post',
contentType: 'application/json',
headers: {
Authorization: 'Bearer ' + accessToken
},
payload: JSON.stringify(payload)
};
var response = UrlFetchApp.fetch(url, options);
Logger.log(response.getContentText());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment