I have been facing problem while coding that while using service account key and using drive.files.list API, i am not able to get files, though i have shared all the files publicly
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)
});
- In result i am getting nothing though i have shared all the files publicly and given edit rights to all.
- In service account i have enable google API and gave qwner permission.
- I want all the publicly share files to list.
- Where i am wrong in the code.
please help me out in this. thanks :)