Created
August 18, 2016 10:54
-
-
Save jincod/8e4355af6aafcf46a2c93086e2e47be4 to your computer and use it in GitHub Desktop.
Update google sheet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const google = require('googleapis'); | |
const sheets = google.sheets('v4') | |
const key = require('./google-key.json'); | |
const scope = [ | |
'https://www.googleapis.com/auth/spreadsheets' | |
]; | |
const spreadsheetId = 'spreadsheetId'; | |
const auth = new google.auth.JWT(key.client_email, null, key.private_key, scope, null); | |
auth.authorize(function(err, tokens) { | |
if (err) { | |
console.log(err); | |
return; | |
} | |
const range = 'Sheet1!A2:F10'; | |
const req = { | |
auth, | |
spreadsheetId, | |
range, | |
valueInputOption: 'USER_ENTERED', | |
resource: { | |
range, | |
values, | |
majorDimension: 'ROWS' | |
} | |
} | |
sheets.spreadsheets.values.update(req, (err, resp) => { | |
if (err) { | |
throw err; | |
} | |
console.log(resp); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment