I am trying to get the file contents of a Google Drive Spreadsheet via node.js. I am using the google-api-nodejs-client to get the access_token
and the node-google-drive module to get the file_id
.
"https://docs.google.com/feeds/download/spreadsheets/Export?key="+file_id+"&exportFormat=csv&gid=0"
When I'm logged into the Google Drive and I go to that URL above it downloads the spreadsheet in CSV format. When I try to go to that URL in incognito it shows a login page, which is the same page I'm getting in the body of my request within node.js.
request({
"method":"get",
"url": "https://docs.google.com/feeds/download/spreadsheets/Export",
"qs":{
"key": key,
"exportFormat": "csv",
"gid": 0
},
"headers":{
"Authorization": "Bearer " + token
}
}, function(err, response, body){
console.log(response);
});
I've tried to send a Authorization
header, but I'm still getting an HTML response. Containing Sorry, the file you have requested does not exist.
Use this: https://github.com/jpillora/node-edit-google-spreadsheet
Example
var Spreadsheet = require('edit-google-spreadsheet');
Spreadsheet.create({
debug: true,
username: [GOOGLE USERNAME],
password: [PASSWORD],
spreadsheetName: 'node-edit-spreadsheet',
worksheetName: 'Sheet1',
spreadsheetId: '[DOC ID]',
callback: run
});
function run(err, spreadsheet) {
if(err) throw err;
//receive all cells
spreadsheet.receive(function(err, rows, info) {
if(err) throw err;
console.log("Found rows:", rows);
console.log("With info:", info);
});
}
Regards,
/t
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With