domainwidedelegation.comStart free

Use cases → Documents and Drive

Automate removal of external Drive file shares

Scan for Google Drive files shared outside the domain and remove those shares automatically using a delegated service account.

Who it is forIT admins responsible for enforcing data-sharing policies across user Drives.
APIsDrive API
Typical scopesdrive

The problem

External file shares are often created ad hoc and forgotten, exposing sensitive data indefinitely. Manual review is slow and patchy, especially at scale.

How it works

  1. List all files in user Drives via the delegated service account.
  2. Identify permissions with 'anyone' or external email addresses.
  3. Remove unwanted permissions directly using the Drive API.
  4. Log every change and notify file owners as required.

What changes

External shares are removed regularly, reducing exposure windows and giving a clear audit trail of changes.

The trap in this one. The Drive API's permissions list is eventually consistent: removing a permission and then immediately querying the file may still show the old state for several seconds. If your automation expects instant feedback or loops until the share is gone, it can create noisy logs or even rate-limit errors. Always build in a delay and verify with a fresh list after some time.

Questions people ask

Does this work for Shared Drives as well as My Drive?

Yes, but you must enumerate Shared Drives separately. Membership and sharing behave differently, so test both cases.

Can users re-share files after removal?

Yes, unless you also restrict sharing settings at the admin level. This pattern only removes existing shares.

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.