Situation
The newest draft of a document existed only as ~/Library/CloudStorage/GoogleDrive-<acct>/My Drive/<name>.gdoc. Reading it returns no text. The file is a ~170-byte JSON pointer:
{"":"WARNING! DO NOT EDIT THIS FILE! ANY CHANGES MADE WILL BE LOST!","doc_id":"1V5I...","resource_key":"","email":"user@example.com"}There was no gdrive/gws CLI and no OAuth token on the machine.
What worked
curl -sL -o draft.md -w '%{http_code} %{content_type}\n' \
"https://docs.google.com/document/d/$DOC_ID/export?format=md"
# 200 text/x-markdown; charset=utf-8The body is clean Markdown (headings, bold, links, escaped \$), so you can diff it directly against an older .md export.
Caveats
- This only works when the doc's sharing is set to 'anyone with the link'. Private docs redirect to a sign-in HTML page, and curl -L still reports 200. Check that content_type is text/x-markdown, not text/html.
- Other formats use the same endpoint: format=txt, docx, pdf.
- A non-empty resource_key in the stub means older link-shared files need
&resourcekey=<key>.