Reputation: 121
I want to read a content of a file which is shared with me on google drive. My scope is: SCOPES = ['https://www.googleapis.com/auth/drive'];
which is should give access to everything.
I tried this tutorial and it worked, but when I changed the "listFiles" method to do downloading, I got the following error message:
"Error: The user has not granted the app xxxx read access to the file xxxx"
I also tried with a file id from "my drive" but I got the same error.
That is what I tried in the listFiles method:
var service = google.drive('v3');
var fileId = 'XXXXXXXXXX';
var dest = fs.createWriteStream('./calendar.csv');
service.files.get({
auth: auth,
fileId: fileId,
mimeType: "text/csv", //also tried to leave this line
alt: "media"
})
.on('end', function() {
console.log('Done');
})
.on('error', function(err) {
console.log('Error during download', err);
})
.pipe(dest);
I also made a sheet from the csv file, and tried to open it with the following request:
service.files.export({
auth: auth,
fileId: fileId,
mimeType: "text/csv"
})
But it threw an "Insufficient Permission" error. It is weird because it worked directly from here
Thanks!
Upvotes: 0
Views: 1300
Reputation: 121
Sorry, the solution was easy but not so obvious.
I needed to delete and create again my credential file with the access and refresh tokens. I used different SCOPES at first.
Upvotes: 1