cold-jewelry-54343
10/18/2023, 6:08 PMjava
const path = require('path');
const {google} = require('googleapis');
const {authenticate} = require('@google-cloud/local-auth');
const sheets = google.sheets('v4');
async function runSample(spreadsheetId, range) {
// Obtain user credentials to use for the request
const auth = await authenticate({
keyfilePath: path.join(__dirname, '../oauth2.keys.json'),
scopes: [
'https://www.googleapis.com/auth/drive',
'https://www.googleapis.com/auth/drive.file',
'https://www.googleapis.com/auth/spreadsheets',
],
});
google.options({auth});
const res = await sheets.spreadsheets.values.append({
spreadsheetId,
range,
valueInputOption: 'USER_ENTERED',
requestBody: {
values: [
['Justin', '1/1/2001', 'Website'],
['Node.js', '2018-03-14', 'Fun'],
],
},
});
console.log(res.data);
return res.data;
}
if (module === require.main) {
const [spreadsheetId, range] = process.argv.slice(2);
runSample(spreadsheetId, range).catch(console.error);
}
module.exports = runSample;
- if we cannot install the Google's Node.js than we are left with using thirdparty software solutions like Zapier and Make.com
- I did find the following video that uses Google Sheet's Webhook add-on: