After reinstalling my node modules I got this error:
Cannot use api key only to create a new spreadsheet - it is only usable for read-only access of public docs
My bare minimum code taken from the official documentation is failing:
import {JWT} from 'google-auth-library'
import {GoogleSpreadsheet} from 'google-spreadsheet';
// I put key redacted here in the issue but used real private key in my code
const key = '-----BEGIN PRIVATE KEY-----(key redacted)-----END PRIVATE KEY-----\n';
const SCOPES = [
'https://www.googleapis.com/auth/spreadsheets',
'https://www.googleapis.com/auth/drive.file',
];
const jwt = new JWT({
email: 'agent@company.iam.gserviceaccount.com',
key,
scopes: SCOPES,
});
GoogleSpreadsheet.createNewSpreadsheetDocument(jwt, {title: 'hello'}))
.then(result => {
console.log('has result!: ', !!result);
}).catch(error => {
console.log(error.message);
});
I figured out that the error is thrown because there is a key called "apiKey" in the JWT. Downgrading the google-auth-library to 9.13.0 has solved the issue for me so I would recommend either fixing the dependency or updating the check that throws the error
After reinstalling my node modules I got this error:
Cannot use api key only to create a new spreadsheet - it is only usable for read-only access of public docsMy bare minimum code taken from the official documentation is failing:
I figured out that the error is thrown because there is a key called "apiKey" in the JWT. Downgrading the google-auth-library to 9.13.0 has solved the issue for me so I would recommend either fixing the dependency or updating the check that throws the error