我在编码时遇到问题,在使用服务帐户密钥和使用 drive.files.list API 时,我无法获取文件,尽管我已经公开共享了所有文件
const { google } = require('googleapis');
const drive = google.drive('v3');
const jwtClient = new google.auth.JWT(
client_email,
null,
private_key,
['https://www.googleapis.com/auth/drive']
);
jwtClient.authorize(function (err, tokens) {
if (err) {
console.log(err);
return;
} else {
console.log("Successfully connected!");
}
});
// List Drive files.
drive.files.list({
auth: jwtClient,
// fields: "files",
includeRemoved: false,
spaces: 'drive'
}, (listErr, resp) => {
if (listErr) {
console.log(listErr);
return;
}
console.log("Result ========>", resp.data.files)
});
- 结果,尽管我已公开共享所有文件并授予所有人编辑权限,但我什么也没得到。
- 在服务帐户中,我启用了 google API 并授予了 qwner 权限。
- 我希望列出所有公开共享文件。
- 我在代码中出错的地方。
请帮我解决这个问题。谢谢 :)