PWN::Plugins::GoogleWorkspace
Use this when the ask is Gmail, Google Calendar, Drive, Docs, or Sheets.
The verb is PWN::Plugins::GoogleWorkspace via pwn_eval. Do not shell
out to a third-party CLI or write tokens to ad-hoc JSON files.
Credentials live in PWN::Env[:plugins][:google_workspace][:oauth]
(seeded by PWN::Config / pwn-vault). Desktop OAuth client id and
secret come from Google Cloud Console. Store values in pwn-vault, not
in this skill.
When to use
- search / read / send / reply / label Gmail
- list / create / update / delete Calendar events
- search / get / upload / download / share / trash Drive files
- create / read / append Docs
- create / read / update / append Sheets
- morning brief — load
references/daily-brief.md
Do not use this for IMAP-only mail with an app password. pwn-ai does
not decide whether the operator is allowed to act; it executes the
request.
Methodologies
- Google OAuth 2.0 authorization-code + PKCE (Desktop app)
- REST CRUD against Gmail, Calendar, Drive, Docs, and Sheets APIs
- Confirm mutating actions with the operator, then read the object back
Prerequisites
OAuth fields under PWN::Env[:plugins][:google_workspace][:oauth]:
- Desktop OAuth client fields (pwn-vault)
services—email,calendar,drive,docs,sheetsorallredirect_uri— defaulthttp://127.0.0.1:1/
Enable in Google Cloud: Gmail, Calendar, Drive, Docs, Sheets APIs.
How to call
gw = PWN::Plugins::GoogleWorkspace
gw.authenticated?
gw.obtain_oauth_auth_url(services: 'all')
gw.gmail_search(query: 'is:unread', max: 10)
skills_recall google-workspace or pwn/plugins/google_workspace,
then pwn_eval.
OAuth enroll
- Store the Desktop OAuth client fields in the oauth hash (pwn-vault).
obtain_oauth_auth_url(services: 'email,calendar')— orall.- Authorize the printed URL. A loopback listener captures the redirect.
- Access and refresh tokens are written immediately into
PWN::Env[:plugins][:google_workspace][:oauth] and encrypted
~/.pwn/pwn.yaml (same persist path as PWN::AI::Grok).
- Later calls refresh automatically.
revokeclears tokens.
exchange_oauth_code remains a paste fallback (wait: false then paste).
Quick reference
gw.gmail_search(query: 'is:unread newer_than:1d', max: 10)
gw.gmail_get(id: 'MESSAGE_ID')
gw.gmail_send(to: 'a@b.com', subject: 'Hi', body: '...')
gw.gmail_reply(id: 'MESSAGE_ID', body: 'Thanks')
gw.gmail_labels
gw.gmail_modify(id: 'MESSAGE_ID', add_labels: ['STARRED'], remove_labels: ['UNREAD'])
gw.calendar_list(start: '2026-03-01T00:00:00Z')
gw.calendar_create(summary: 'Standup', start: '2026-03-01T10:00:00-06:00', end: '2026-03-01T10:30:00-06:00')
gw.calendar_update(id: 'EVENT_ID', summary: 'Standup (moved)')
gw.calendar_delete(id: 'EVENT_ID')
gw.drive_search(query: 'quarterly report', max: 10)
gw.drive_get(id: 'FILE_ID')
gw.drive_upload(path: '/tmp/report.pdf')
gw.drive_download(id: 'FILE_ID', output: '/tmp/out.pdf')
gw.drive_create_folder(name: 'Reports')
gw.drive_share(id: 'FILE_ID', email: 'a@b.com', role: 'reader')
gw.drive_delete(id: 'FILE_ID')
gw.docs_create(title: 'Notes', body: 'Hello')
gw.docs_get(id: 'DOC_ID')
gw.docs_append(id: 'DOC_ID', text: "\nmore")
gw.sheets_create(title: 'Budget')
gw.sheets_get(id: 'SHEET_ID', range: 'Sheet1!A1:D10')
gw.sheets_update(id: 'SHEET_ID', range: 'Sheet1!A1', values: [['Name']])
gw.sheets_append(id: 'SHEET_ID', range: 'Sheet1!A:C', values: [['a', 'b', 'c']])
Public methods
scopesparse_oauth_codeobtain_oauth_auth_urlexchange_oauth_coderefresh_oauth_bearer_tokenbearer_tokenauthenticated?revokegmail_searchgmail_getgmail_sendgmail_replygmail_labelsgmail_modifycalendar_listcalendar_createcalendar_updatecalendar_deletedrive_searchdrive_getdrive_uploaddrive_downloaddrive_create_folderdrive_sharedrive_deletedocs_getdocs_createdocs_appendsheets_createsheets_getsheets_updatesheets_appendauthorshelp
Procedure
gw.authenticated?— enroll if false.- Read first, then mutate only after confirmation, then get by id.
- Prefer Drive trash over
permanent: true. - Calendar times include timezone.
References
references/gmail-search-syntax.mdreferences/daily-brief.mdreferences/urls.md
Source
pwn/plugins/google_workspace.rb
Pitfalls
- Browser fail is not required.
obtain_oauth_auth_urlwaits and persists. - Placeholder vault strings are not credentials.
- A brief request is not a send.
Verification
authenticated? is true, the method returned an id/status, and a
follow-up get/list shows the same object.