google-api-nodejs-client
google-api-nodejs-client copied to clipboard
How to set the X-Goog-Drive-Resource-Keys HTTP header while using the googleapis npm package?
Got this email about the security update that is going to be enforced on sept 13 2021, and i was trying to figure out how to actually set the X-Goog-Drive-Resource-Keys HTTP header with fileID and resourceKey (the Drive API guide) as its value while listing files in google drive but could not figure out how while using this package. Kindly help.
Thank you.
Hi @RakshithNM , have you found the answer? I'm looking for this, too.
@pnyennhi not yet, please let me know here if you find the answer
Hi @RakshithNM, I think I found the way to set the X-Goog-Drive-Resource-Keys HTTP header for drive API. I'm using create API and setting like this:
var fileMetadata = {
'name': 'photo.jpg'
};
var media = {
mimeType: 'image/jpeg',
body: fs.createReadStream('files/photo.jpg')
};
drive.files.create({
resource: fileMetadata,
media: media,
fields: 'id',
headers: {
'X-Goog-Drive-Resource-Keys': 'fileId1/resourceKey1,fileId2/resourceKey2,fileId3/resourceKey3'
}
}, function (err, file) {
if (err) {
// Handle error
console.error(err);
} else {
console.log('File Id: ', file.id);
}
});
You can try this one and see if it works.
I 'm wondering which API I should include this resourceKey
header, such as create
, update
, delete
or more...
Hi @RakshithNM , have you found the answer? I'm looking for this, too.