// 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.file',
],
});
// 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.permissions.patch({
// The ID for the file or shared drive.
fileId: 'placeholder-value',
// The ID for the permission.
permissionId: 'placeholder-value',
// Whether to remove the expiration date.
removeExpiration: 'placeholder-value',
// Whether the requesting application supports both My Drives and shared drives.
supportsAllDrives: 'placeholder-value',
// Deprecated use supportsAllDrives instead.
supportsTeamDrives: 'placeholder-value',
// Whether changing a role to 'owner' downgrades the current owners to writers. Does nothing if the specified role is not 'owner'.
transferOwnership: 'placeholder-value',
// Issue the request as a domain administrator; if set to true, then the requester will be granted access if the file ID parameter refers to a shared drive and the requester is an administrator of the domain to which the shared drive belongs.
useDomainAdminAccess: 'placeholder-value',
// Request body metadata
requestBody: {
// request body parameters
// {
// "additionalRoles": [],
// "authKey": "my_authKey",
// "deleted": false,
// "domain": "my_domain",
// "emailAddress": "my_emailAddress",
// "etag": "my_etag",
// "expirationDate": "my_expirationDate",
// "id": "my_id",
// "kind": "my_kind",
// "name": "my_name",
// "permissionDetails": [],
// "photoLink": "my_photoLink",
// "role": "my_role",
// "selfLink": "my_selfLink",
// "teamDrivePermissionDetails": [],
// "type": "my_type",
// "value": "my_value",
// "view": "my_view",
// "withLink": false
// }
},
});
console.log(res.data);
// Example response
// {
// "additionalRoles": [],
// "authKey": "my_authKey",
// "deleted": false,
// "domain": "my_domain",
// "emailAddress": "my_emailAddress",
// "etag": "my_etag",
// "expirationDate": "my_expirationDate",
// "id": "my_id",
// "kind": "my_kind",
// "name": "my_name",
// "permissionDetails": [],
// "photoLink": "my_photoLink",
// "role": "my_role",
// "selfLink": "my_selfLink",
// "teamDrivePermissionDetails": [],
// "type": "my_type",
// "value": "my_value",
// "view": "my_view",
// "withLink": false
// }
}
main().catch(e => {
console.error(e);
throw e;
});
// 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.apps.readonly',
'https://www.googleapis.com/auth/drive.file',
'https://www.googleapis.com/auth/drive.metadata',
'https://www.googleapis.com/auth/drive.metadata.readonly',
'https://www.googleapis.com/auth/drive.photos.readonly',
'https://www.googleapis.com/auth/drive.readonly',
],
});
// 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.permissions.getIdForEmail({
// The email address for which to return a permission ID
email: 'placeholder-value',
});
console.log(res.data);
// Example response
// {
// "id": "my_id",
// "kind": "my_kind"
// }
}
main().catch(e => {
console.error(e);
throw e;
});
// 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('v3');
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.file',
'https://www.googleapis.com/auth/drive.metadata',
'https://www.googleapis.com/auth/drive.metadata.readonly',
'https://www.googleapis.com/auth/drive.photos.readonly',
'https://www.googleapis.com/auth/drive.readonly',
],
});
// 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.permissions.get({
// The ID of the file.
fileId: 'placeholder-value',
// The ID of the permission.
permissionId: 'placeholder-value',
// Whether the requesting application supports both My Drives and shared drives.
supportsAllDrives: 'placeholder-value',
// Deprecated use supportsAllDrives instead.
supportsTeamDrives: 'placeholder-value',
// Issue the request as a domain administrator; if set to true, then the requester will be granted access if the file ID parameter refers to a shared drive and the requester is an administrator of the domain to which the shared drive belongs.
useDomainAdminAccess: 'placeholder-value',
});
console.log(res.data);
// Example response
// {
// "allowFileDiscovery": false,
// "deleted": false,
// "displayName": "my_displayName",
// "domain": "my_domain",
// "emailAddress": "my_emailAddress",
// "expirationTime": "my_expirationTime",
// "id": "my_id",
// "kind": "my_kind",
// "permissionDetails": [],
// "photoLink": "my_photoLink",
// "role": "my_role",
// "teamDrivePermissionDetails": [],
// "type": "my_type",
// "view": "my_view"
// }
}
main().catch(e => {
console.error(e);
throw e;
});