domainwidedelegation.comStart free

Use casesDocuments and Drive

Implement dynamic access expiry for Shared Drives

A delegated service account reviews and revokes Shared Drive membership on a schedule, enforcing time-based access for external or internal users.

Who it is forIT administrators managing time-limited access to Shared Drives for contractors, projects, or rotating teams.
APIsDrive API, Admin SDK
Typical scopesdrive, admin.directory.group.readonly

The problem

Temporary collaboration often outlives its intended window, leaving Shared Drives accessible to users who no longer need them. Manual review is unreliable and doesn't scale, especially across dozens or hundreds of drives and group memberships.

How it works

  1. A delegated service account enumerates Shared Drives and their memberships on a regular schedule.
  2. It cross-references each member against an expiry policy, which may be set by group membership, custom attributes, or external records.
  3. For members whose access has expired, it calls the Drive API to remove them from the Shared Drive.
  4. It logs every removal, including the membership and drive identifiers, for audit and troubleshooting.
  5. Optionally, it notifies affected users or administrators of upcoming or completed revocations.

What changes

Access windows are enforced without manual effort, reducing risk from orphaned permissions and making audits straightforward.

The trap in this one. Drive API membership removals are eventually consistent. If you remove a user and immediately re-enumerate, the membership may still appear for several seconds — so a naive script can mistakenly treat removals as failures and retry, leading to spurious errors or excessive API calls. Batch jobs that process drives in rapid succession are especially prone to this, and error logs will reflect removals that actually succeeded.

Questions people ask

Can I set expiry natively in Google Drive?

Drive supports expiry for file and folder sharing with individuals, but not for Shared Drive memberships. Automating removals is the only way to enforce true membership expiry.

How do I avoid removing the wrong user?

Always track removals by both user email and role, and avoid wildcard deletions. Logging every action with identifiers is essential for later audit.

Want this built?

This is a pattern we run in production. We will set up the delegation and build this on top of it — $500 per hour, most of it working the same day.

Talk to us Or read the setup guide

Related use cases

Auto-provision shared drives for every new project

Spin up a new shared drive for each project, with the right permissions and structure, as soon as the project is created.

Automated monitoring for external sharing violations

Detect and report when Drive files or folders are shared outside the organisation using a delegated service account.

Automate project folder creation and access assignment

Create a Drive folder for each new project and assign the correct access immediately, without waiting for manual intervention.