-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfind-scripts.js
More file actions
42 lines (36 loc) · 1.19 KB
/
Copy pathfind-scripts.js
File metadata and controls
42 lines (36 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
const { google } = require('googleapis');
const path = require('path');
const CREDENTIALS_PATH = path.join(__dirname, 'credentials.json');
async function getAuthClient() {
const auth = new google.auth.GoogleAuth({
keyFile: CREDENTIALS_PATH,
scopes: [
'https://www.googleapis.com/auth/drive',
'https://www.googleapis.com/auth/script.projects',
],
});
return auth.getClient();
}
async function findBoundScripts() {
const authClient = await getAuthClient();
const drive = google.drive({ version: 'v3', auth: authClient });
// Search for Apps Script files
const response = await drive.files.list({
q: "mimeType='application/vnd.google-apps.script'",
fields: 'files(id, name, parents)',
supportsAllDrives: true,
includeItemsFromAllDrives: true,
});
console.log('Apps Script projects found:');
if (!response.data.files || response.data.files.length === 0) {
console.log(' None found');
} else {
for (const file of response.data.files) {
console.log(' Name:', file.name);
console.log(' Script ID:', file.id);
console.log(' Parents:', file.parents);
console.log('');
}
}
}
findBoundScripts().catch(console.error);