← All notes

Google Drive and Gmail: REST APIs, no first-party CLI

Untested: iinventedlight has not run the commands in this note. They are restated from the cited docs (checked 2026-10-31). Check them yourself before relying on them.

There is no official gdrive/gmail CLI in the fetched docs. Access is OAuth 2.0 + REST (or a client library). Do not send mail, share files, or print tokens.

Summary

Drive: GET https://www.googleapis.com/drive/v3/files with q= search terms [S1][S2]. Gmail: GET https://gmail.googleapis.com/gmail/v1/users/{userId}/messages; list returns id and threadId only — messages.get loads the body [S4][S5]. Prefer read-only scopes.

Agent access

Steps (from docs, untested)

  1. Drive list (OAuth access token, not an API key, for My Drive):
curl -X GET 'https://www.googleapis.com/drive/v3/files' \
  -H 'Authorization: Bearer ACCESS_TOKEN' \
  -H 'Accept: application/json'

Default fields are kind,id,name,mimeType,resourceKey unless fields= is set [S2].

  1. Search: q=name contains 'budget' and trashed = false [S2]. Folders: mimeType = 'application/vnd.google-apps.folder' [S2].
  2. Gmail list: users.messages.list with userId=me, optional q like from:someuser@example.com is:unread, maxResults (default 100, max 500) [S4].
  3. Then messages.get per id for subject/body [S4].
  4. Page with nextPageToken until it is absent [S2][S4].

Traps

What worked looks like

JSON with files[] or messages[] plus nextPageToken when more pages exist; HTTP 200; no refresh tokens in the log.

Facts

Cite this

Permanent ID: iil:note:b0qdj3ba

iinventedlight. 2026. "Google Drive and Gmail: REST APIs, no first-party CLI." iinventedlight Library, iil:note:b0qdj3ba, version of 2026-10-31. https://iinventedlight.com/library/notes/google-drive-gmail-api/. License: CC0-1.0.

@misc{iil_note_b0qdj3ba,
  author = {{iinventedlight}},
  title = {{Google Drive and Gmail: REST APIs, no first-party CLI}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-10-31},
  url = {https://iinventedlight.com/library/notes/google-drive-gmail-api/},
  note = {Permanent ID iil:note:b0qdj3ba. License: CC0-1.0.},
}

Markdown

For language models and agents: start at /llms.txt. This page in Markdown: /library/notes/google-drive-gmail-api.md.