jpillora / node-edit-google-spreadsheet

A simple API for editing Google Spreadsheets
304 stars 101 forks source link

Adds docs.google.com/feeds to default OAuth scopes #30

Closed colinhicks closed 10 years ago

colinhicks commented 10 years ago

When using OAuth, it's apparently now necessary to pass an additional scope to the JWT auth request: https://docs.google.com/feeds

Without it, requests for spreadsheet data 404, yielding downstream errors like:

TypeError: Cannot read property 'feed' of undefined
  at /your-app/node_modules/edit-google-spreadsheet/lib/index.js:421:15

Caveat: I have not seen any documentation from Google about this change. It is possible that it's unintended on their part. At the moment, their own OAuth Playground returns 404s for spreadsheet API requests built with the wizard – unless you manually add the https://docs.google.com/feeds scope.

screen shot 2014-04-30 at 9 58 04 am

See also this stackoverflow thread from the past 12 hours.

colinhicks commented 10 years ago

BTW, a separate workaround is to explicitly specify oauth.scopes within the options arg:

Spreadsheet.load({
  debug: true,
  spreadsheetName: 'node-edit-spreadsheet',
  worksheetName: 'Sheet1',
  oauth: {
    email: 'my-name@google.email.com',
    keyFile: 'my-private-key.pem',
    scopes: ['https://spreadsheets.google.com/feeds', 'https://docs.google.com/feeds']
  }
}, function sheetReady(err, spreadsheet) {
// ...
});
jpillora commented 10 years ago

hey Colin, thanks for the PR :)