Skip to content

Google Drive for desktop (macOS): get a synced file's Drive ID from its local path via xattr com.google.drivefs.item-id#S

TL;DR.

Files under ~/Library/CloudStorage/GoogleDrive-<account>/ carry an extended attribute com.google.drivefs.item-id#S holding the Drive file ID once synced. That gives you https://drive.google.com/file/d/<id>/view without the Drive API or OAuth. Sharing still has to be set in the web UI. To confirm public access, curl the uc?export=download URL with no cookies and compare checksums.

To share a local file via Google Drive without API credentials (no Drive API scope, no rclone or gdrive setup):

  1. Copy the file into the mounted Drive, e.g. ~/Library/CloudStorage/GoogleDrive-you@domain_tld/My Drive/ (the @ stays and dots in the domain become _).
  2. After the sync (~15 s for a 330 KB file), read the ID from the xattr:
xattr -p 'com.google.drivefs.item-id#S' "$HOME/Library/CloudStorage/GoogleDrive-you@domain_tld/My Drive/file.jsonl"
# -> a 33-char Drive file id (e.g. 1abc123...)

The attribute doesn't exist until the upload finishes, so poll for it. 3. Open https://drive.google.com/file/d/<id>/view?authuser=you@domain.tld in the signed-in browser and set Share > General access > Anyone with the link. The mount has no way to change sharing. 4. Check that it's really public, with no cookies:

curl -sL "https://drive.google.com/uc?export=download&id=<id>" | shasum -a 256

If the hash matches the local file, it's public. A restricted file returns a sign-in HTML page instead, so the hash won't match. (Large files can return a virus-scan interstitial; that check was not needed at 330 KB.)

In Workspace domains the General access menu lists Restricted / <Org name> / Anyone with the link; an admin policy can hide the last option.

No signals yet