// 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',
'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.children.list({
// The ID of the folder.
folderId: 'placeholder-value',
// Maximum number of children to return.
maxResults: 'placeholder-value',
// A comma-separated list of sort keys. Valid keys are 'createdDate', 'folder', 'lastViewedByMeDate', 'modifiedByMeDate', 'modifiedDate', 'quotaBytesUsed', 'recency', 'sharedWithMeDate', 'starred', and 'title'. Each key sorts ascending by default, but may be reversed with the 'desc' modifier. Example usage: ?orderBy=folder,modifiedDate desc,title. Please note that there is a current limitation for users with approximately one million files in which the requested sort order is ignored.
orderBy: 'placeholder-value',
// Page token for children.
pageToken: 'placeholder-value',
// Query string for searching children.
q: 'placeholder-value',
});
console.log(res.data);
// Example response
// {
// "etag": "my_etag",
// "items": [],
// "kind": "my_kind",
// "nextLink": "my_nextLink",
// "nextPageToken": "my_nextPageToken",
// "selfLink": "my_selfLink"
// }
}
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.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.parents.get({
// The ID of the file.
fileId: 'placeholder-value',
// The ID of the parent.
parentId: 'placeholder-value',
});
console.log(res.data);
// Example response
// {
// "id": "my_id",
// "isRoot": false,
// "kind": "my_kind",
// "parentLink": "my_parentLink",
// "selfLink": "my_selfLink"
// }
}
main().catch(e => {
console.error(e);
throw e;
});
const {google} = require('googleapis');
const drive = google.drive('v3');
const {google} = require('googleapis');
const drive = google.drive('v2');
// 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.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.teamdrives.list({
// Maximum number of Team Drives to return.
pageSize: 'placeholder-value',
// Page token for Team Drives.
pageToken: 'placeholder-value',
// Query string for searching Team Drives.
q: 'placeholder-value',
// Issue the request as a domain administrator; if set to true, then all Team Drives of the domain in which the requester is an administrator are returned.
useDomainAdminAccess: 'placeholder-value',
});
console.log(res.data);
// Example response
// {
// "kind": "my_kind",
// "nextPageToken": "my_nextPageToken",
// "teamDrives": []
// }
}
main().catch(e => {
console.error(e);
throw e;
});