Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Google Apps Script version for using authenticated data sources
function getResults() {
var connector = {'username':'YOUR_SITE_USERNAME',
var creds = {};
creds[connector.connectorDomain] = {
"username": connector.username,
"password": connector.password
var additionalInput = {};
additionalInput[connector.connectorGuid] = {'domainCredentials':creds};
//get cookies
var login = query(connector.connectorGuid, false, connector.userGuid, connector.apiKey, additionalInput, false);
additionalInput[connector.connectorGuid].cookies = login.cookies;
var result = query(connector.connectorGuid, {"webpage/url":""}, connector.userGuid, connector.apiKey, additionalInput, false);
// do something with results like write to Google Sheet
function query(connectorGuid, input, userGuid, apiKey, additionalInput, login) {
var url = "" + connectorGuid + "/_query?_user=" + userGuid + "&_apikey=" + apiKey;
var data = {};
if (input) {
data["input"] = input;
if (additionalInput) {
data["additionalInput"] = additionalInput;
if (login) {
data["loginOnly"] = true;
var ch = UrlFetchApp.fetch(url, {'method':'POST', 'payload': JSON.stringify(data)});
var result = ch.getContentText();
return JSON.parse(result);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.