Google Workspace Plugin
Lets the assistant work in the signed-in user's Gmail, Calendar, Docs, Sheets, and Drive — search and read by default, and (after approval) send mail, manage events, edit documents, and manage Drive files. Each user connects their own Google account; there is no shared instance credential.
It sits on top of the OAuth plugin, which stores tokens and runs the Google consent flow. Users connect from Settings → Extensions → Google Workspace; they never have to visit a separate "OAuth" screen.
Using it
Connect your Google account
The first time, register this Codumentor with Google once — see Google Cloud project below. Until then, Settings says the connection isn't set up yet.
- Open Settings (gear icon) → Extensions → Google Workspace.
- Choose which products to grant, and at which level:
| Product | Read only | Broader grant |
|---------|-----------|----------------|
| Gmail | Search and read mail | Read & send — also send, draft, label, and trash (not permanent deletion) |
| Calendar | List calendars and read events | Manage events — also create, update, and delete events |
| Docs | Read document text | Read & edit — also create documents and edit text |
| Sheets | Read spreadsheet values | Read & edit — also create spreadsheets and edit values |
| Drive | Find files by name or full text and download them (PDFs, images, exports of Docs/Sheets/Slides) | Read & manage — also create folders, upload files, rename, move, copy, trash, and share |
- Click Connect. Google's consent screen opens in the browser. After you approve, Codumentor stores the grant for your user.
- You can later narrow or broaden those choices in the same settings section, or disconnect the account.
The assistant only receives tools that match the products and levels you granted. If you connect Gmail as read-only, it cannot send mail until you raise that level and reconnect.
The TUI has the same picker under Settings → Google Workspace.
Talk to the assistant
Once connected, ask in ordinary language, for example:
- "What unread mail did I get from Alice this week?"
- "Put a 30-minute review on my calendar tomorrow at 10."
- "Find the Q2 planning Doc and summarise the risks section."
- "Add a row to the expenses Sheet for today's lunch."
Read tools run without a prompt. Anything that sends mail, changes a calendar, edits a Doc/Sheet, or changes Drive asks for approval first (Allow once / Allow for this conversation / Create a rule / Deny), the same way a shell command does.
If you are not connected, or a needed product is missing, the tool returns a message pointing you back to Settings → Google Workspace — it does not call Google.
What the assistant can do
Gmail
The optional Mail plugin offers account-scoped mail_* names through
this same connection. Legacy names below retain their schemas, raw IDs and
approval labels; saved goals are not rewritten. When mail policy is enabled,
legacy writes also obey its account read-only restriction.
| Tool | Approval | Purpose |
|---|---|---|
gmail_search | none | Search or list messages (Gmail search syntax, e.g. from:alice is:unread) |
gmail_get_message | none | Read one message (headers, body, attachment list) |
gmail_get_thread | none | Read a whole conversation |
gmail_list_drafts | none | List saved drafts |
gmail_list_labels | none | List labels / folders |
gmail_get_attachment | none | Download one attachment into the staging area so it can be copied into a repo — the bytes do not enter the chat |
gmail_send | gmail.send | Send a new message, or send an existing draft |
gmail_draft | gmail.draft | Create or update a draft |
gmail_delete_draft | gmail.draft | Discard a draft |
gmail_modify_message | gmail.modify | Add/remove labels (read/unread, archive, star, move) |
gmail_trash_message | gmail.trash | Move a message to Trash, or restore it |
gmail_manage_label | gmail.label | Create, rename, or delete a label |
Permanent Gmail deletion is not exposed.
Calendar
| Tool | Approval | Purpose |
|---|---|---|
calendar_list_calendars | none | List calendars the account can see |
calendar_list_events | none | List events in a time window |
calendar_get_event | none | Read one event in full |
calendar_create_event | calendar.event.create | Create an event |
calendar_update_event | calendar.event.update | Update an event |
calendar_delete_event | calendar.event.delete | Delete an event |
Drive, Docs, Sheets
| Tool | Approval | Purpose |
|---|---|---|
drive_search | none | Find Docs/Sheets (and other files) by name or full text |
drive_get_file | none | One file's metadata: folders, sharing, export formats |
drive_download_file | none | Save a file (or a Doc/Sheet/Slides export) to the attachment staging area |
drive_create_folder | drive.create_folder | Create a folder |
drive_upload_file | drive.upload | Upload a workspace file, optionally converted to a Doc/Sheet/Slides, or as a new version of an existing file |
drive_update_file | drive.update | Rename, move, or set the description |
drive_copy_file | drive.copy | Copy a file (formatting and tabs preserved) |
drive_trash_file | drive.trash | Move to or restore from the trash (never deletes permanently) |
drive_share_file | drive.share | Share with a person, group, domain, or anyone with the link |
drive_unshare_file | drive.unshare | Remove one sharing permission |
docs_get_document | none | Read a Doc as compact text |
docs_create_document | docs.create | Create a Doc |
docs_replace_text | docs.edit | Replace exact text matches |
docs_insert_text | docs.edit | Insert text at an anchor |
sheets_get_spreadsheet | none | Spreadsheet overview (tabs) |
sheets_read_values | none | Read an A1 range |
sheets_create_spreadsheet | sheets.create | Create a spreadsheet |
sheets_update_values | sheets.edit | Write an A1 range |
sheets_append_values | sheets.edit | Append rows |
sheets_clear_values | sheets.edit | Clear an A1 range |
drive_search is how the assistant finds a Doc or Sheet; the Docs/Sheets tools then open it by id. drive_download_file stores bytes the same way Gmail attachments are stored: the agent gets a path to copy, not the contents in context. Google-native files are exported (Docs default to PDF, Sheets to XLSX, Slides to PDF); Google caps exports at 10 MB. drive_upload_file reads files up to 100 MB from the conversation workspace. The write tools need the Read & manage Drive level (drive scope); an account connected with Drive read-only keeps only the three read tools.
Who gets which half
Two gates, not one. target_agents (default main) decides whether the family is offered at all; write_target_agents (default main) then decides who gets the tools in the "Approval" column above.
The family default stays closed because these tools act on a real mailbox and calendar, and nobody reads a subagent's tool calls before they land. The second gate is what makes opening it a decision about reading: with target_agents: all, a research subagent can search mail and list events, and still cannot send, edit, trash, or delete anything. Set write_target_agents: all only if subagents should write too.
Configuration
Personal (community) install: both plugins are already switched on. There is nothing to add here; go straight to Google Cloud project.
For a custom configuration, load both plugins. This plugin's priority must be lower than OAuth's (3 vs 4) so Google is available when OAuth starts serving connect flows.
plugins:
- module: codumentor.plugins.oauth
class: OAuthPlugin
priority: 4
args:
enabled: true
- module: codumentor.plugins.google_workspace
class: GoogleWorkspacePlugin
priority: 3
args:
enabled: true
Connecting an account requires the oauth:manage permission, which the built-in power_user and admin roles have. Grant it to other roles if ordinary users should connect Google themselves.
The configuration loader automatically creates and persists auth.jwt_secret for token encryption; no manual secret setup is needed for a personal install (see OAuth). Localhost works without a public URL or api.external_url. For a remotely accessible deployment, set api.external_url to the externally reachable base URL.
Google Cloud project
Connect stays unavailable until Google recognizes this Codumentor. That is a one-time registration of Codumentor as an app in a Google Cloud account. If you run Codumentor yourself, you do it; if someone else runs it, they do. It costs nothing for this use and takes about ten minutes. You end up with two values, a client ID and a client secret, which you give to Codumentor.
The steps below assume the usual personal setup: Codumentor runs on your own computer and you open it at http://127.0.0.1:2638/app. If it runs on a server that others reach over the network, read Running Codumentor on a server first, because one address changes.
1. Create a project
- Open Google Cloud Console and sign in with the Google account you want the assistant to use.
- Click the project picker at the top of the page → New project. Any name works, for example
Codumentor. Click Create and make sure the new project is selected.
2. Turn on the Google APIs
Open APIs & Services → Library, search for each of these, open it and click Enable:
- Gmail API
- Google Calendar API
- Google Docs API
- Google Sheets API
- Google Drive API
You only need the ones for the products you plan to connect, but enabling all five does no harm.
3. Set up the consent screen
This is the page Google shows when you click Connect. Open APIs & Services → OAuth consent screen (newer consoles call it Google Auth Platform) and fill it in:
- App name: anything, for example
Codumentor. - User support email and developer contact: your own address.
- Audience (or User type):
- Personal Gmail account: choose External. Then, under Test users, add your own Gmail address. Without this, Google refuses the sign-in with "Access blocked".
- Company Google Workspace account: choose Internal if you are allowed to. Everyone in your organization can then connect, and there are no test users to maintain.
You can skip the optional fields (logo, domains, scopes). Codumentor asks for the scopes itself when you connect.
4. Create the client ID
- Open APIs & Services → Credentials (or Clients) → Create credentials → OAuth client ID.
- Application type: Web application. Name: anything.
- Under Authorized redirect URIs, click Add URI and paste exactly:
````
http://127.0.0.1:2638/oauth/callback/google
Copy it character for character: http, not https; 127.0.0.1, not localhost; port 2638; no slash at the end. Google compares this address literally, so http://localhost:2638/... counts as a different address and fails. (If you changed Codumentor's port, use your port instead of 2638.)
- Click Create. Google shows the Client ID (ends in
.apps.googleusercontent.com) and the Client secret (usually starts withGOCSPX-). Keep this window open, or download the JSON, for the next step.
5. Give the two values to Codumentor
On a personal install, open Settings → Extensions → Google Workspace and paste the client ID and secret into the fields there, then click Save. They are stored encrypted with your other secrets. Connect is available straight away; no restart. The same two values can be added under Settings → Extensions → User Secrets, named google_oauth_client_id and google_oauth_client_secret, marked host-only. The Google page reads those names.
A shared installation keeps them in configuration instead (credentials: config, the default there). Put them in the deployment configuration, then restart Codumentor:
plugins:
- module: codumentor.plugins.google_workspace
class: GoogleWorkspacePlugin
priority: 3
args:
credentials: config
client_id: "123456789012-abc123.apps.googleusercontent.com"
client_secret: "GOCSPX-your-secret"
On your own machine, if you would rather keep them in your personal settings file than paste them in Settings, use plugins_overrides: in config.yaml (~/.codumentor/config.yaml; on Windows C:\Users\<you>\.codumentor\config.yaml) and set credentials: config with the two values. Use plugins_overrides:, not plugins:: a plugins: list in that file replaces the whole built-in list and switches off every other extension. Keep the indentation (spaces, not tabs). Then restart.
To keep the secret out of files entirely, set two environment variables before starting Codumentor. They are also the fallback when credentials is user_secret and you have not pasted values yet; once you save secrets, those take over.
# Linux / macOS: add to ~/.bashrc or ~/.zshrc, then open a new terminal
export GOOGLE_OAUTH_CLIENT_ID="123456789012-abc123.apps.googleusercontent.com"
export GOOGLE_OAUTH_CLIENT_SECRET="GOCSPX-your-secret"
:: Windows: run once in a Command Prompt, then open a new one
setx GOOGLE_OAUTH_CLIENT_ID "123456789012-abc123.apps.googleusercontent.com"
setx GOOGLE_OAUTH_CLIENT_SECRET "GOCSPX-your-secret"
6. Connect
If you pasted the values on the Google Workspace page, click Connect there. If you put them in configuration or the environment, restart Codumentor first (Ctrl+C in its window, or close the window), then open Settings → Extensions → Google Workspace and click Connect.
If connecting does not work
| What you see | What to do |
|---|---|
| Settings says the connection isn't set up yet | Codumentor did not find the client ID and secret. On a personal install, paste them into the fields on that page and click Save. Otherwise check config.yaml or the environment variables in the window you start Codumentor from, then restart. |
| Google shows Error 400: redirect_uri_mismatch | The redirect URI in step 4 does not match. Compare it character by character with http://127.0.0.1:2638/oauth/callback/google; the error page's details show the address Codumentor actually sent. Saving a change in Google can take a few minutes to apply. |
| Google shows Access blocked or "has not completed the Google verification process" | Add your Google address under Test users (step 3). |
| Google warns "Google hasn't verified this app" | Expected for an app you made yourself. Click Continue (or Advanced → Go to Codumentor). |
| You have to reconnect about once a week | Google expires the sign-in after 7 days while the consent screen's publishing status is Testing. Either reconnect when asked, or set the status to In production under OAuth consent screen → Audience. For an app only you use, Google then shows the "not verified" warning once at sign-in, and you click through it as above. |
| A Google API error says the API has not been used or is disabled | Enable that API in step 2, wait a minute, and try again. |
Running Codumentor on a server
Everything above holds, except the redirect URI. When people open Codumentor at another address, for example https://codumentor.example.com, set that address as api.external_url in the configuration and register <api.external_url>/oauth/callback/google in step 4:
api:
external_url: "https://codumentor.example.com"
The redirect URI to register is then https://codumentor.example.com/oauth/callback/google. Without api.external_url, Codumentor always sends http://<api.host>:<api.port>/oauth/callback/google, by default http://127.0.0.1:2638/oauth/callback/google, which only works in a browser on the same machine. In a shared installation, each user still connects their own Google account; nobody shares a token.
If the client ID and secret are missing, the plugin still loads but does not offer Google: Settings says the connection isn't set up yet, the tools cannot call Google, and Codumentor keeps running.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
enabled | bool | true | Master on/off. |
credentials | string | user_secret on community, config otherwise | user_secret: the client ID and secret are host-only user secrets, pasted on the Google Workspace settings page. config: client_id / client_secret below, or the environment variables. |
client_id | string | $GOOGLE_OAUTH_CLIENT_ID | OAuth client id. Used when credentials is config, and as a fallback in user_secret until secrets are saved. |
client_secret | string | $GOOGLE_OAUTH_CLIENT_SECRET | OAuth client secret. Same rules as client_id. |
client_id_secret | string | google_oauth_client_id | Secret name for the client id when credentials is user_secret. |
client_secret_secret | string | google_oauth_client_secret | Secret name for the client secret when credentials is user_secret. |
default_scopes | list | Gmail/Calendar/Docs/Sheets/Drive read-write + openid/email | Scopes requested when the user clicks Connect without changing the picker. The picker still offers every product/level. |
filter_tools_by_scope | bool | true | Only offer tools whose scopes the connected account actually grants. |
revoke_on_narrow | bool | true | When the user drops a product or level, revoke the Google grant and re-consent so the removed access is gone upstream, not only locally. |
target_agents | string | main | Who gets the tools: main, subagent, all, or a subagent role name. Default keeps this family off subagents entirely. |
write_target_agents | string | main | Same values, applied to the editing tools only — so widening target_agents grants reads without also granting gmail_send. |
authorize_url / token_url / userinfo_url / revocation_url | string | Google's public endpoints | Override only to point at a private Google-compatible IdP. |
Read-only default grant
To have Connect request read access unless the user raises a product in the picker:
default_scopes:
- openid
- email
- https://www.googleapis.com/auth/gmail.readonly
- https://www.googleapis.com/auth/calendar.readonly
- https://www.googleapis.com/auth/documents.readonly
- https://www.googleapis.com/auth/spreadsheets.readonly
- https://www.googleapis.com/auth/drive.readonly
Notes
- Each user authenticates as themselves. Two people in the same Codumentor instance never share a Google token.
- Attachment and Drive downloads are saved under the instance attachment staging area so the agent can copy them into a repo; size is capped by
agent.attachment_staging.max_file_bytes. - Narrowing access re-opens Google's consent screen (needed so a refresh token is re-issued for the smaller grant).
- See OAuth for
api.external_url,auth.jwt_secret, and the callback URL.
See also
- OAuth — connect flows, encrypted tokens,
api.external_url - User Secrets — where a personal install stores the Google app's client ID and secret (
credentials: user_secret) - Permissions — how write-tool approval works