我正在使用google节点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);
}
});
它很好地工作并生成工作表,当我显示响应对象时,我得到到电子表格的链接:
spreadsheetUrl:"QHxPUQcGqZGAzFHkHZV-RSKsv5IpJazcjVpLTYkk/edit“
但是当我试图在浏览器中打开它时,我做不到:You need permission
。问题是,如果我单击Request access
按钮,我认为它实际上会从凭据Request access
发送一个请求到client_email
,这样它就不能工作了。如果我以编程方式打开电子表格,它就能工作.
有人知道如何在浏览器中打开生成的电子表格吗?
发布于 2017-09-20 00:52:19
下面是一个解决方案:https://github.com/google/google-api-nodejs-client/issues/804#issuecomment-327931203
需要使用Google为该文件授予权限
https://stackoverflow.com/questions/45812388
复制