domainwidedelegation.comStart free

Use casesDocuments and Drive

Set and renew Drive permissions on a fixed schedule

Automate Drive file access expiry so external or temporary collaborators lose access unless explicitly renewed, enforcing least-privilege over time.

Who it is forIT administrators and compliance teams managing external or time-limited sharing.
APIsDrive API
Typical scopesdrive

The problem

Temporary access is rarely revoked on time. Files are shared for a project or with a vendor, but nobody tracks when access should end, leading to ongoing exposure. Manual review is tedious and unreliable, especially at scale.

How it works

  1. Enumerate all permissions on shared files using a delegated service account.
  2. Tag each permission with an expiry timestamp as a custom property or in an external database.
  3. On a scheduled job, check for expired permissions and remove them using the Drive API.
  4. Notify file owners or relevant parties about upcoming expiries and offer a renewal process.
  5. If renewed, re-add or extend the permission, resetting the expiry timestamp.

What changes

Access is not left open indefinitely. Temporary collaborators lose access automatically unless someone takes action to renew, reducing accidental data leaks.

The trap in this one. The Drive API's permission removal is eventually consistent: after deleting a permission, querying the same file may still show the old permission for several minutes. If the script loops back too quickly, it may attempt to remove the same permission again, triggering 404 errors or rate limits. This is particularly problematic when running expiry jobs in tight schedules or parallel batches, as it can mask whether a permission was actually removed or never existed.

Questions people ask

Can expiry dates be set natively in Drive?

Drive supports expiry for some link-shares but not for all permission types, especially individual users. This pattern tracks and enforces expiry externally.

What happens if a permission is renewed after expiry?

The automation re-adds the permission, which creates a new permission ID. Any tracking must update to reflect the new ID, or future expiry cycles may miss it.

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

Create a client folder structure the moment a deal closes

Provision a consistent Drive folder tree, seeded with templates and shared with the right people, automatically.

Generate documents from a template and real data

Produce agreements, letters and reports from a Docs template with fields filled from your systems.

Sort incoming files into the right place automatically

Watch a drop folder, work out what each file is, and file it where it belongs with a consistent name.