Set up Gmail CLI authentication with OAuth2
Guides you through OAuth2 setup for the gmail CLI. You'll need to create credentials in Google Cloud Console, install gmaillm, and run authentication to enable Gmail API access for automation tasks.
/plugin marketplace add WarrenZhu050413/Warren-Claude-Code-Plugin-Marketplace/plugin install gmail-plugin@warren-claude-code-plugin-marketplaceThis command guides you through setting up the gmail CLI for the first time.
You need OAuth2 credentials from Google Cloud Console.
~/.gmaillm/oauth-keys.json:
mkdir -p ~/.gmaillm
mv ~/Downloads/client_secret_*.json ~/.gmaillm/oauth-keys.json
chmod 600 ~/.gmaillm/oauth-keys.json
# Install from source
cd ~/.claude/plugins/gmail-plugin/scripts/gmaillm
make install
Run the setup command:
gmail setup-auth
This will:
~/.gmaillm/credentials.jsonIf port 8080 is in use:
gmail setup-auth --port 8081
gmail verify
Expected output:
Gmail API authentication: OK
# Re-run authentication
python3 -m gmaillm.setup_auth
# If port is blocked
python3 -m gmaillm.setup_auth --port 9999
# Kill any existing auth processes
pkill -f "gmaillm.setup_auth"
# Try a different port
gmail setup-auth --port 8081
The CLI searches for OAuth keys in this order:
~/.gmaillm/oauth-keys.json (recommended)${CLAUDE_PLUGIN_ROOT}/credentials/oauth-keys.json (plugin mode)~/Desktop/OAuth2/gcp-oauth.keys.json (fallback)~/.gmaillm/
├── oauth-keys.json # OAuth2 client secrets (0600)
├── credentials.json # Saved credentials (0600)
├── email-groups.json # Email distribution groups
├── output-style.json # Output formatting preferences
└── email-styles/ # Email style templates
├── professional-formal.md
├── professional-friendly.md
└── casual-friend.md
Enable tab completion for faster typing:
gmail --install-completion
exec $SHELL
/gmail - Usage guide for gmail CLI