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

Authentication recently stopped working #39

Closed pietersv closed 9 years ago

pietersv commented 9 years ago

This library worked great for me until a week or so ago, now authentication does not appear to work. This returns an error value which converts to string as [Error: Login failed]. The email / pwd are correct and the sheet key is valid. The sheet is readable without auth if I make it public.

If I inspect the error object, it has a lots of properties including '404' and 'Not Found` which makes me wonder if the Google API it is using might have changed recently?

var GoogleSpreadsheet = require("google-spreadsheet");
var my_sheet = new GoogleSpreadsheet(SPREADSHEET_KEY);
my_sheet.setAuth(GOOGLE_EMAIL, GOOGLE_PWD, function (err, val) {
  if (err) {
    console.log(err); // [Error: Login failed]
    console.log(err.data); //  https://developers.google.com/accounts/docs/AuthForInstalledApps
    console.log(err.response.statusCode); // 404 
    console.log(err.response.statusMessage); // Not Found
    console.log(val); // undefined 
  }
  else console.log("Success");
});
pietersv commented 9 years ago

Aha, as of May 27, 2015

Important: ClientLogin has been officially deprecated since April 20, 2012 and is now no longer available. Requests to ClientLogin will fail with a HTTP 404 response. We encourage you to migrate to OAuth 2.0 as soon as possible.

https://developers.google.com/identity/protocols/AuthForInstalledApps

theoephraim commented 9 years ago

I'll be working on getting something built into the module ASAP, but for now there is a workaround. Ongoing discussion here: https://github.com/theoephraim/node-google-spreadsheet/issues/38

Unfortunately, it will no longer be as simple as just using a username and password, but it shouldn't be too bad.

ralyodio commented 9 years ago

I also ran into this problem.

christiaanwesterbeek commented 9 years ago

Me too.

Update: But the solution described here got it all working again: https://github.com/theoephraim/node-google-spreadsheet/issues/38#issuecomment-107597356

AlexClineBB commented 9 years ago

I did as well. :(

theoephraim commented 9 years ago

Just released v1.0.0 with instructions and tools for using a service account instead of the deprecated clientlogin (username + password). Please check it out and let me know if there are any bugs!

pietersv commented 9 years ago

Works perfectly. The docs are clear as well. Thanks!