There is no way of downloading a list with all your current properties. This video shows you how to connect your HubSpot portal to Google Sheet and get a list of all your contact properties into Google Sheets.
Here is the OAuth2 library used in the tutorial: 1B7FSrk5Zi6L1rSxxTDgDEUsPzlukDsi4KGuTMorsTQHhGBzBkMun4iDF
A lot of the steps are based on two Medium articles from Alexis Bedoret:
[ Ссылка ]
[ Ссылка ]
Here is the Script used (don't forget to add your own Client ID and Client secret):
var CLIENT_ID = '...'; // Enter your Client ID
var CLIENT_SECRET = '...'; // Enter your Client secret
var SCOPE = 'contacts';
var AUTH_URL = '[ Ссылка ]';
var TOKEN_URL = '[ Ссылка ]';
var API_URL = '[ Ссылка ]';
function getService() {
return OAuth2.createService('hubspot')
.setTokenUrl(TOKEN_URL)
.setAuthorizationBaseUrl(AUTH_URL)
.setClientId(CLIENT_ID)
.setClientSecret(CLIENT_SECRET)
.setCallbackFunction('authCallback')
.setPropertyStore(PropertiesService.getUserProperties())
.setScope(SCOPE);
}
function authCallback(request) {
var service = getService();
var authorized = service.handleCallback(request);
if (authorized) {
return HtmlService.createHtmlOutput('Success!');
} else {
return HtmlService.createHtmlOutput('Denied.');
}
}
function authenticate() {
var service = getService();
if (service.hasAccess()) {
// … whatever needs to be done here …
} else {
var authorizationUrl = service.getAuthorizationUrl();
Logger.log('Open the following URL and re-run the script: %s',authorizationUrl);
}
}
function refresh() {
var service = getService();
if (service.hasAccess()) {
var stages = getStages();
writeStages(stages);
var deals = getDeals();
writeDeals(deals);
} else {
var authorizationUrl = service.getAuthorizationUrl();
Logger.log('Open the following URL and re-run the script: %s', authorizationUrl);
}
}
function writeResults(sheetName,results)
{
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName(sheetName);
sheet.clear();
var setRange = sheet.getRange(1,1,results.length,results[0].length);
setRange.setValues(results);
}
function getProperties() {
// Authentication to Hubspot
var service = getService();
var options = {headers: {'Authorization': 'Bearer ' + service.getAccessToken()}};
var numResults = 0;
// We are going to put all the date into that array, starting with the header of our sheet
var data = new Array();
data.push(["CONTACT PROPERTIES"]);
// More info about contacts api here:
// [ Ссылка ]
var url_query = API_URL + "/contacts/v1/lists";
var response = UrlFetchApp.fetch(url_query, options).getContentText();
response = JSON.parse(response);
response.forEach(function(item) {
data.push([item.name]);
numResults++;
});
Logger.log(numResults);
// This function will clear and fill in the sheet with the data
writeResults("PROPERTIES",data);
}
![](https://s2.save4k.ru/pic/7vH8w8JdzFQ/maxresdefault.jpg)