拒绝访问创建的电子表格谷歌节点 API



我正在使用谷歌节点API来生成电子表格。我使用的第三方库是官方库(https://github.com/google/google-api-nodejs-client(。以下是我用于生成电子表格的代码:

var sheets = google.sheets('v4');
sheets.spreadsheets.create({
auth: auth,
resource: {
properties:{
title: "Google export"
}
}
}, (err, response) => {
if (err) {
console.log('The API returned an error: ' + err);
return;
} else {
console.log("Added");
res.send(response);
}
});

它工作正常并生成工作表,当我显示响应对象时,我得到了电子表格的链接:

电子表格网址:"https://docs.google.com/spreadsheets/d/1XS_QHxPUQcGqZGAzFHkHZV-RSKsv5IpJazcjVpLTYkk/edit">

但是当我尝试在浏览器中打开它时,我无法:You need permission. 问题是,如果我单击Request access按钮,我认为它实际上从我的凭据(user@project-174309.iam.gserviceaccount.com(向client_email发送请求,因此它不起作用。 如果我以编程方式打开电子表格,它可以工作...

有谁知道如何在浏览器中打开生成的电子表格?

这是一个解决方案: https://github.com/google/google-api-nodejs-client/issues/804#issuecomment-327931203

需要使用谷歌云端硬盘 API 来授予此文件的权限

最新更新