theoephraim / node-google-spreadsheet

Google Sheets API wrapper for Javascript / Typescript
https://theoephraim.github.io/node-google-spreadsheet
The Unlicense
2.33k stars 390 forks source link

createNewSpreadsheetDocument 400 bad request 4.1.2 #697

Open Ivokato opened 3 months ago

Ivokato commented 3 months ago

After updating my dependencies I got an inexplicable ERR_BAD_REQUEST (400) response when trying to create new google spreadsheets through createNewSpreadsheetDocument. I tried doing the same from RunKit (where every npm module is installed) and there it did work with the same input. When I learnt that the RunKit uses 4.1.1 instead of 4.1.2 I downgraded my local package version and my issue was resolved. Here is my minimal reproduction code:

var {JWT} = require("google-auth-library");
var {GoogleSpreadsheet} = require("google-spreadsheet")

const key = '-----BEGIN PRIVATE KEY-----insert-your-actual-key-----END PRIVATE KEY-----\n';

const auth = new JWT({
  email: 'quality-agent@company.iam.gserviceaccount.com',
  key,
  scopes: [
    'https://www.googleapis.com/auth/spreadsheets',
    'https://www.googleapis.com/auth/drive.file',
  ],
});

GoogleSpreadsheet.createNewSpreadsheetDocument(auth, {title: 'test'}).then(console.log).catch(e => console.log('error', e));
theoephraim commented 3 months ago

Oh! Very weird. I’ll take a look. Thanks!

theoephraim commented 1 month ago

@Ivokato - I suspect this may have been related to https://github.com/theoephraim/node-google-spreadsheet/issues/701 Please give the latest version a try!