tech/google/workspace/drive

DRIVE

Google Drive API skill (stub). Use when: (1) creating, reading, or updating files/folders via Drive API v3,

production Drive API v3, Drive Activity API v2

Google Drive API (stub)

Status: stub. Production depth pending.

Scope choice

ScopeGrantsNotes
drive.fileOnly files your app creates or is opened withPrefer this — no verification audit
drive.readonlyRead all of user's DriveRestricted scope
drive.metadata.readonlyMetadata only, no contentRestricted scope
driveFull accessRestricted scope, avoid unless needed

Quick start

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

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',
});

Gotchas (high-level)

See Also