NodeOps
CN

Google Workspace CLI Integration

Overview

The Google Workspace CLI provides a command-line interface for working with Gmail, Docs, Sheets, and other Google Workspace services. Use it to script workflows, automate tasks, and build tools that interact with your emails, documents, and spreadsheets from your terminal.


Prerequisites

  • Node.js and npm
  • A Google account with access to Google Workspace services
  • A Google OAuth application (Google Cloud Console)
  • A terminal (Cursor, VS Code terminal, or standard terminal)

Setup Instructions

Step 1: Install the CLI

Open your terminal and run:

Bash
1npm install -g @googleworkspace/cli

Once installed, the gws command is available in your terminal.

Video: Installing Google Workspace CLI

Installing Google Workspace CLI

Step 2: Setup Authentication

Run:

Bash
1gws auth setup

If the CLI reports a missing dependency, install it when prompted and run the command again.

Credentials are typically stored at:

~/.config/gws/client_secret.json

You may need to create or configure a Google OAuth client depending on your environment.

Step 3: Login

Authenticate with your Google account:

Bash
1gws auth login --account [email protected]

Video: Authentication Setup

Google Workspace CLI setup and login

Step 4: Verify Setup

List files from Google Drive:

Bash
1gws drive files list --params '{"pageSize": 5}'

Send a test email from the terminal:

Bash
1gws gmail +send --to [email protected] --subject 'from terminal' --body 'hello! from the terminal!'

Video: Testing the CLI

Testing Google Workspace CLI and sending email

Step 5: Troubleshooting Authentication

If commands do not return results, check authentication status:

Bash
1gws auth list

If no credentials appear, export them manually:

Bash
1gws auth export --unmasked > ~/gws-credentials.json
2export GOOGLE_WORKSPACE_CLI_CREDENTIALS_FILE=~/gws-credentials.json

Then run the verification command again:

Bash
1gws drive files list --params '{"pageSize": 5}'

Example Commands

View all available commands:

Bash
1gws --help

The CLI includes 100+ prebuilt skills for different Google Workspace APIs. Full list: skills.md

Send an email:

Bash
1gws gmail +send --to [email protected] --subject "From terminal" --body "Hello from the terminal!"

Get Gmail profile:

Bash
1gws gmail users getProfile --params '{"userId": "me"}'

What You Can Build

  • Automated email workflows
  • AI agents that use Workspace tools
  • Scripts that read or update Google Sheets
  • Internal tools powered by Workspace APIs

Demo Video

End to end install: Demo

Google Workspace CLI demo

100,000+ 构建者,同一个工作空间。

获取产品更新、构建者故事,以及帮助您更快交付的新功能抢先体验。

CreateOS 是一个统一的智能工作空间,让创意从概念到上线部署无缝衔接,消除工具、基础设施和工作流之间的上下文切换,并可在 CreateOS 市场上即时实现创意变现。