makeFeedRequest with GZIP throws Error: "incorrect header check"
Running the document.getInfo(function(err, data) {}) function is resulting in an exception being thrown by browserfy-zlib. This can be traced back to the request from the makeFeedRequest() function. makeFeedRequest specifies gzip: true in the request, which is causing the failure. Manually removing gzip:true resultings in the api working as expected. Below is how i am utizliing the google-spreadsheets api.
I have a the following wrapper API to turn the callbacks into promises:
const GoogleSheetsAPI = () => {
return {
authorize: (sheetsId, credentials) => new Promise((resolve, reject) => {
if (typeof credentials == 'undefined') {
credentials = require(CREDENTIALS_PATH)
}
const doc = new GoogleSpreadsheet(sheetsId);
doc.useServiceAccountAuth(credentials, (err) => {
if (err) reject(err);
resolve(doc);
});
}),
load: (doc) => new Promise((resolve, reject) => {
console.log('getting doc info')
doc.getInfo(function(err, data) {
if (err) reject(err);
resolve(data);
});
})
}
}
`
And call this later by:
gsheetsAPI.authorize(sheetId);
.then(doc => gsheetsAPI.load(doc))
.then(data => {
//DO STUFF
})
.catch(err => console.log(err))
Hello, I was having this same problem. I have a web app that was tested and working using this package. It recently broke -- not sure if it was last months package update, or that Google updated their Sheets API from v3 to v4.
Regardless, I'm using React with Express middleware. I added the following to set compression headers to false. After doing so, my web app works again.
var express = require('express');
var app = express();
const port = process.env.PORT || 5000;
app.listen(port, function() {
console.log('Listening on port ' + port + '...');
function addHeader() { // set if not set by end of request
if (!this.getHeader('gzip')) {
this.setHeader('gzip', 'false') // turn off gzip compression
}
if (!this.getHeader('Accept-Encoding')) {
this.setHeader('Accept-Encoding', 'identity') // turn off all compression
}
}
}
@cwolf22 Were you able to track down this error?
No, I'm still using the fix described earlier.
Getting the same error on a Vue JS application. Made a PR to fix this issue.
should be fixed!
For anyone looking for how to get it to work:
Initialize the doc like this
const doc = new GoogleSpreadsheet('<Spreadsheet ID>', null, { gzip: false })
Thanks a lot!, now it's working fine !
For anyone looking for how to get it to work: Initialize the doc like this
const doc = new GoogleSpreadsheet('<Spreadsheet ID>', null, { gzip: false })