Google Drive API skill (stub). Use when: (1) creating, reading, or updating files/folders via Drive API v3,
Status: stub. Production depth pending.
| Scope | Grants | Notes |
|---|---|---|
drive.file | Only files your app creates or is opened with | Prefer this — no verification audit |
drive.readonly | Read all of user's Drive | Restricted scope |
drive.metadata.readonly | Metadata only, no content | Restricted scope |
drive | Full access | Restricted scope, avoid unless needed |
import { google } from 'googleapis';
const drive = google.drive({ version: 'v3', auth });
// Create a folder
const { data: folder } = await drive.files.create({
requestBody: { name: 'Client 2n-014 intake', mimeType: 'application/vnd.google-apps.folder' },
fields: 'id,name,webViewLink',
});
// Upload a file into it
const { data: file } = await drive.files.create({
requestBody: { name: 'contract.pdf', parents: [folder.id!] },
media: { mimeType: 'application/pdf', body: fs.createReadStream('./contract.pdf') },
fields: 'id,webViewLink',
});
// Grant someone view access
await drive.permissions.create({
fileId: file.id!,
requestBody: { role: 'reader', type: 'user', emailAddress: '[email protected]' },
sendNotificationEmail: true,
});
Shared drives (formerly Team Drives) are owned by the organisation, not a person. Files survive employee offboarding. Always check supportsAllDrives: true on list/search calls.
const { data } = await drive.files.list({
q: "'DRIVE_ID' in parents",
supportsAllDrives: true,
includeItemsFromAllDrives: true,
driveId: 'DRIVE_ID',
corpora: 'drive',
});
supportsAllDrives: true, shared-drive files are invisible.drive.file scope hides files the app didn't create/open — including copies. Copy flows break silently.