For whom: a step-by-step guide to set up
gclifrom scratch for your own Google account. Works for a human or for an AI coding agent (Claude Code) following along.
gcli is a command-line tool for working with Google services from the terminal:
- Gmail — read, search, send mail
- Google Drive — files, folders, upload/download
- Google Sheets — read, write, create
- Google Calendar — view, create, edit events
- Google Docs — read, create, append text
Each user runs it against their own Google Cloud project and OAuth credentials. This repo contains no keys.
- macOS or Linux
- Python 3.9+
- pip3
- A Google account
- A browser (for the one-time OAuth authorization)
git clone https://github.com/ambymon/google-cli.git
cd google-cliYou only need these files (already in the repo):
google-cli/
setup.py
requirements.txt
.gitignore
gcli/
__init__.py
main.py
auth.py
output.py
mail.py
drive.py
sheets.py
calendar.py
docs.py
IMPORTANT: the repo does not ship
credentials.jsonortoken.json. You create your own in the next steps. Never commit them.
These steps happen in the browser. An AI agent can't do them for you.
- Open console.cloud.google.com
- Sign in with your Google account
- Click the project picker at the top → New Project
- Name it (e.g.
my-cli-tools) - Click Create
- Make sure the new project is selected at the top
Go to APIs & Services → Library and enable each of these (click Enable):
- Gmail API
- Google Drive API
- Google Sheets API
- Google Calendar API
- Google Docs API
- Go to APIs & Services → OAuth consent screen
- Choose External (unless you're on Google Workspace) → Create
- Fill in:
- App name: anything (e.g.
My CLI) - User support email: your email
- Developer contact email: your email
- App name: anything (e.g.
- Click Save and Continue
- On Scopes — just click Save and Continue (scopes are requested at login time)
- On Test users — add your own email (the same Google account)
- Save and Continue → Back to Dashboard
- Go to APIs & Services → Credentials
- Click Create Credentials → OAuth client ID
- Application type: Desktop app
- Name: anything (e.g.
gcli) - Click Create
- In the dialog, click Download JSON
- Save the file as
credentials.jsonin thegoogle-cli/folder (next tosetup.py)
From the google-cli/ folder:
pip3 install -r requirements.txt
pip3 install -e .Check it installed:
gcli --helpIt should list the command groups (mail, drive, sheets, calendar, docs, auth).
Run:
gcli auth status- A browser opens with the Google authorization page
- Pick your account
- You may see "Google hasn't verified this app" — click Advanced → Go to My CLI (unsafe). This is normal for an app in testing mode that only you use.
- Click Continue / Allow for the requested permissions
- On success the terminal confirms it
A token.json file is created automatically — it stores your authorization token.
gcli mail list --max 3
gcli drive ls
gcli calendar events
gcli sheets list
gcli docs listIf those work, you're done.
The agent calls gcli via shell commands. For programmatic parsing always add --json:
gcli --json mail list --max 5
gcli --json drive ls
gcli --json calendar events --days 7| Service | Commands |
|---|---|
| Gmail | mail list, mail search "query", mail read <id>, mail send --to --subject --body, mail reply <id> --body, mail drafts, mail draft --to --subject --body |
| Drive | drive ls [folder_id], drive search "name", drive upload <path>, drive download <id> <path>, drive mkdir "name", drive delete <id> |
| Sheets | sheets list, sheets read <id> [--range], sheets write <id> --range --data, sheets create "name" |
| Calendar | calendar events [--days N], calendar create --title --start --end, calendar edit <id>, calendar delete <id> |
| Docs | docs list, docs read <id>, docs create "name" [--body], docs append <id> --text |
| Problem | Fix |
|---|---|
credentials.json not found |
Download the OAuth client JSON from Google Cloud Console (Step 2.4) and save it next to setup.py |
Access blocked: app not verified |
Click Advanced → Go to ... (unsafe). Normal for testing mode |
gcli: command not found |
Run pip3 install -e . again, or use python3 -m gcli |
Token has been expired or revoked |
Delete token.json and run gcli auth status again |
Quota exceeded |
Wait a minute and retry, or check API limits in Cloud Console |
- Never share
credentials.jsonortoken.json— they grant access to your Google account - Both are in
.gitignore - Tokens are stored locally only
- Delete commands always ask for confirmation