How to use the googleapis.sheets function in googleapis

To help you get started, we’ve selected a few googleapis examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github google / ground-platform / functions / gnd-sheets.js View on Github external
'use strict';

const google = require('googleapis');

const sheets = google.sheets('v4');

// TODO: Use single quotes everywhere except JSON for consistency.
const ELEMENT_ID_COLUMN_METADATA_KEY = 'elementId';
const RECORD_ID_ROW_METADATA_KEY = 'recordId';
const LAT_COLUMN_ID = '_latColumn';
const LNG_COLUMN_ID = '_lngColumn';
const GEOPOINT_LAT = '_latitude';
const GEOPOINT_LNG = '_longitude';

function columnElementIdsRequest() {
  return {
    dataFilters: [
      {
        developerMetadataLookup: {
          locationType: "COLUMN",
          locationMatchingStrategy:
github UnaBiz / sigfox-gcloud / lib / googlesheets.js View on Github external
const stringify = require('json-stringify-safe');
const google = require('googleapis');
const common = require('../index');
/* eslint-disable import/no-unresolved */
/* process.env.GCLOUD_PROJECT
  ? require('../index')
  : require('./common'); */ /* eslint-enable import/no-unresolved */

//  Ensure the Google service account in sigfoxgcloud.keyfilename
//  has these permission scopes: Sheets API, Drive API.
const SCOPES = [
  'https://www.googleapis.com/auth/spreadsheets',
  'https://www.googleapis.com/auth/drive',
];
const sheets = google.sheets('v4');
const drive = google.drive('v3');

const sheetName = 'Log';  //  We will only read and update this sheet.
const headerRange = '1:1';  //  First row contains the header cells.
const tableRange = 'A1';  //  Table starts from this cell.
const valueInputOption = 'RAW';  //  Enter values exactly as keyed in, no interpretation.

let allSpreadsheets = null;  //  Maps filename to id.
let allSheetHeaders = {};  //  Cache the sheet headers by filename.
let allSheetRows = {};  //  Buffer when writing sheet rows, index by filename.
let authClient = null;  //  Authenticated Google API client.

function prefix(action) {
  //  For Cloud Function, log without prefix. Else log with a prefix.
  if (common.isCloudFunc) return action;
  return ['googlesheets', action].join('/');
github mstraughan86 / Scry / scripts / quickstart.js View on Github external
return new Promise(function (resolve, reject) {
    const sheets = google.sheets('v4');
    const options = {
      spreadsheetId: SPREADSHEET_ID,
      range: RANGE,
    };

    sheets.spreadsheets.values.get(options, function (err, response) {
      if (err) {
        console.log('The API returned an error: ' + err);
        reject(err);
        return;
      }
      const rows = response.values;
      if (rows.length == 0) {
        console.log('No data found.');
        reject('No data found.');
        return;
github NUKnightLab / storyline / server.js View on Github external
app.get('/spreadsheets/:id', function(req,res) {
     let sheets = google.sheets('v4')
     sheets.spreadsheets.values.get({
       auth: 'API_KEY',
       spreadsheetId: req.params.id,
       range: 'dates_unemployment'
     },function(err, response) {
       if(err) {console.log('API returned an error')}
       res.send(response)
     })
  })
github firebase / functions-samples / google-sheet-sync / functions / index.js View on Github external
getAuthorizedClient().then(client => {
      const sheets = google.sheets('v4');
      const request = requestWithoutAuth;
      request.auth = client;
      sheets.spreadsheets.values.append(request, (err, response) => {
        if (err) {
          console.log(`The API returned an error: ${err}`);
          return reject();
        }
        return resolve(response);
      });
    }).catch(() => reject());
  });
github r3volved / LaZBot / utilities / gsheetsAPI.js View on Github external
function listMajors(auth) {
    		var sheets = google.sheets('v4');
    		
    		const mysql = require('mysql');

        	const con = mysql.createConnection({
          	  host: botSettings.database.host,
          	  user: botSettings.database.user,
          	  password: botSettings.database.password,
          	  database: botSettings.database.database
          	});

    		try {
    			con.connect(function(err) {
    				if (err) { throw err; }
    				  
        			const sql = "SELECT `spreadsheet` FROM `channel` WHERE `channelID`=?";
        			con.query(sql, [message.channel.id], function (err, result, fields) {
github novoda / spikes / enews / subscriber-node / google-sheets.js View on Github external
const google = require('googleapis');
const sheets = google.sheets('v4');

function GoogleSheets(config) {
  this.jwtClient = new google.auth.JWT(
    config.client_email,
    null,
    config.private_key,
    ['https://www.googleapis.com/auth/spreadsheets'],
    null
  );
}

GoogleSheets.prototype.authenticate = function() {
  const self = this;
  return new Promise(function(resolve, reject) {
    self.jwtClient.authorize(function (err, tokens) {
      if (err) {
github paulirish / pwmetrics / lib / sheets / gsheets.ts View on Github external
async function getRange(auth: Oauth2Client, range: number, spreadsheetId: string): Promise> {
  try {
    const sheets = google.sheets('v4');
    const response = await promisify(sheets.spreadsheets.values.get)({
      auth: auth,
      spreadsheetId: spreadsheetId,
      range: range
    });
    return response.values;
  } catch(error) {
    logger.error(getMessage('G_SHEETS_API_ERROR', error));
    throw new Error(error);
  }
}
github mozilla-frontend-infra / firefox-health-dashboard / src / perf.js View on Github external
const { values } = await new Promise((resolve) => {
    const sheets = google.sheets('v4');
    sheets.spreadsheets.values.get(
      {
        auth: jwtClient,
        spreadsheetId: id,
        range: range,
      },
      (err, response) => resolve(response),
    );
  });
  const headers = values.splice(0, 1).pop();
github rocket-internet-berlin / RocketDashboard / server / src / service / googleSheetsService.js View on Github external
constructor(config) {
    GoogleSheetsService.validateConfig(config);

    this.sheets = google.sheets('v4');

    this.jwtClient = new google.auth.JWT(
      config.serviceAccountEmail,
      null,
      config.serviceAccountPrivateKey,
      ['https://www.googleapis.com/auth/spreadsheets.readonly'],
      null,
    );
  }