// Before running the sample:
// - Enable the API at:
// https://console.developers.google.com/apis/api/drive.googleapis.com
// - Login into gcloud by running:
// `$ gcloud auth application-default login`
// - Install the npm module by running:
// `$ npm install googleapis`
const {google} = require('googleapis');
const drive = google.drive('v2');
async function main() {
const auth = new google.auth.GoogleAuth({
// Scopes can be specified either as an array or as a single, space-delimited string.
scopes: [
'https://www.googleapis.com/auth/drive',
'https://www.googleapis.com/auth/drive.appdata',
'https://www.googleapis.com/auth/drive.file',
'https://www.googleapis.com/auth/drive.metadata',
],
});
// Acquire an auth client, and bind it to all future calls
const authClient = await auth.getClient();
google.options({auth: authClient});
// Do the magic
const res = await drive.properties.patch({
// The ID of the file.
fileId: 'placeholder-value',
// The key of the property.
propertyKey: 'placeholder-value',
// The visibility of the property. Allowed values are PRIVATE and PUBLIC. (Default: PRIVATE)
visibility: 'placeholder-value',
// Request body metadata
requestBody: {
// request body parameters
// {
// "etag": "my_etag",
// "key": "my_key",
// "kind": "my_kind",
// "selfLink": "my_selfLink",
// "value": "my_value",
// "visibility": "my_visibility"
// }
},
});
console.log(res.data);
// Example response
// {
// "etag": "my_etag",
// "key": "my_key",
// "kind": "my_kind",
// "selfLink": "my_selfLink",
// "value": "my_value",
// "visibility": "my_visibility"
// }
}
main().catch(e => {
console.error(e);
throw e;
});