小编lam*_*ams的帖子

Gaxios - NodeJS - Spreadsheet Google 不支持此文档的此操作

我正在尝试根据以下代码访问电子表格中的信息,但出现此错误,我不太明白其原因。

我已经在谷歌上授予了凭据电子邮件的许可...

const { google } = require("googleapis");
const creds = require("./config/gCredentials.json");

const client = new google.auth.JWT(
  creds.client_email,
  null,
  creds.private_key,
  ["https://www.googleapis.com/auth/spreadsheets"]
);

client.authorize(function (err, tokens) {
  if (err) {
    console.log(err);
  } else {
    console.log("connected");
    gsrun(client);
  }
});

async function gsrun(cl) {
  const gsapi = google.sheets({ version: "v4", auth: cl });

  const opt = {
    spreadsheetId: "XYZ",
    range: "SheetA!A1:B14",
  };

  let data = await gsapi.spreadsheets.values.get(opt);
  console.log(data);
}
Run Code Online (Sandbox Code Playgroud)

知道它可能是什么吗?

错误控制台

connected
(node:31301) UnhandledPromiseRejectionWarning: Error: This operation is not supported for this document …
Run Code Online (Sandbox Code Playgroud)

google-api node.js google-drive-api google-cloud-platform

9
推荐指数
1
解决办法
1902
查看次数