domainwidedelegation.comStart free

Use cases → Documents and Drive

Bulk remove external sharing from Drive files

Audit and revoke third-party access to Drive files in bulk using a service account, to close off lingering external shares after projects or audits.

Who it is forIT admins or compliance teams cleaning up shared content across the domain.
APIsDrive API, Admin SDK
Typical scopesdrive, admin.directory.user.readonly

The problem

Over time, files and folders accumulate external sharing, exposing data well beyond its intended audience. Manual removal is slow, error-prone, and impossible at scale, especially when owners have left or ignore requests.

How it works

  1. Enumerate all users with active accounts using the Admin SDK.
  2. For each user, impersonate them and list their Drive files and permissions.
  3. Identify permissions granted to external users or domains.
  4. Batch remove external permissions using the Drive API.

What changes

External sharing is removed in a controlled, auditable process, reducing the risk of accidental data leaks and tightening compliance.

The trap in this one. Drive API batch permission removals are eventually consistent: files can appear to lose external shares but revert if the owner is concurrently active or if permissions are re-synced from shared drives. This leads to 'phantom' shares reappearing hours later, particularly if you do not pause or retry after each batch for propagation. Always re-query after completion to confirm state, and expect to repeat the process for some files.

Questions people ask

Does this remove sharing from Shared Drives?

Yes, but only if the service account is a manager on the Shared Drive. Otherwise, files owned by Shared Drives may be missed.

Will users be notified when their links are revoked?

No, Drive doesn't notify users when sharing permissions are removed via the API. Communicate major changes through other channels.

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

Reassign Drive permissions in bulk with delegation

Use a delegated service account to change or transfer Drive file permissions at scale, for user transitions or access audits.

Automatically remove ex-employees from Shared Drives

Use delegated automation to ensure former staff are promptly and reliably removed from all Shared Drives they could access.

Audit cross-domain file sharing in Google Drive

Detect and report files shared outside the organisation using delegated access, so admins can act before data leaks escalate.