Skip to content

Commit 635f773

Browse files
authored
feat(auth): add guided Google setup (#865)
* feat(auth): add guided Google setup * fix(auth): preserve client in setup guidance
1 parent 861adbd commit 635f773

11 files changed

Lines changed: 566 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
- Evals: add reproducible structural and live Codex/OpenClaw gog/gws comparisons with correctness assertions, token/tool/latency metrics, cache-counterbalanced repetitions, methodology, and CI coverage.
66
- CLI: add `GOG_HELP=agent` compact root help with common read-only recipes and targeted schema guidance so agents can execute Gmail, Calendar, and Drive tasks without traversing multiple help levels.
7+
- Auth: add `auth setup` for guided Google Cloud project/API preparation, OAuth client installation, and optional browser authorization.
78

89
## 0.30.0 - 2026-06-21
910

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,7 @@ Docs: [Auth clients](docs/auth-clients.md),
607607
Store a Desktop OAuth client once:
608608

609609
```bash
610+
gog auth setup [email protected] --gcloud-project my-gog-project --enable-apis --open-console
610611
gog auth credentials ~/Downloads/client_secret_....json
611612
gog auth add [email protected] --services gmail,calendar,drive
612613
```

docs/commands.generated.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ Generated from `gog schema --json`.
5252
- [`gog auth service-account status <email>`](commands/gog-auth-service-account-status.md) - Show stored service account key status
5353
- [`gog auth service-account unset <email>`](commands/gog-auth-service-account-unset.md) - Remove stored service account key
5454
- [`gog auth services [flags]`](commands/gog-auth-services.md) - List supported auth services and scopes
55+
- [`gog auth setup [<email>] [flags]`](commands/gog-auth-setup.md) - Guide Google Cloud, OAuth client, and account setup
5556
- [`gog auth status`](commands/gog-auth-status.md) - Show auth configuration and keyring backend
5657
- [`gog auth tokens <command>`](commands/gog-auth-tokens.md) - Manage stored refresh tokens
5758
- [`gog auth tokens delete <email>`](commands/gog-auth-tokens-delete.md) - Delete a stored refresh token

docs/commands/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Every `gog` command has a generated docs page. The source of truth is the live CLI schema; run `make docs-commands` after changing command names, flags, help text, aliases, or arguments.
44

5-
Generated pages: 694.
5+
Generated pages: 695.
66

77
## Top-level Commands
88

@@ -103,6 +103,7 @@ Generated pages: 694.
103103
- [gog auth service-account status](gog-auth-service-account-status.md) - Show stored service account key status
104104
- [gog auth service-account unset](gog-auth-service-account-unset.md) - Remove stored service account key
105105
- [gog auth services](gog-auth-services.md) - List supported auth services and scopes
106+
- [gog auth setup](gog-auth-setup.md) - Guide Google Cloud, OAuth client, and account setup
106107
- [gog auth status](gog-auth-status.md) - Show auth configuration and keyring backend
107108
- [gog auth tokens](gog-auth-tokens.md) - Manage stored refresh tokens
108109
- [gog auth tokens delete](gog-auth-tokens-delete.md) - Delete a stored refresh token

docs/commands/gog-auth-setup.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# `gog auth setup`
2+
3+
> Generated from `gog schema --json`. Do not edit this page by hand; run `make docs-commands`.
4+
5+
Guide Google Cloud, OAuth client, and account setup
6+
7+
## Usage
8+
9+
```bash
10+
gog auth setup [<email>] [flags]
11+
```
12+
13+
## Parent
14+
15+
- [gog auth](gog-auth.md)
16+
17+
## Flags
18+
19+
| Flag | Type | Default | Help |
20+
| --- | --- | --- | --- |
21+
| `--access-token` | `string` | | Use provided access token directly (bypasses stored refresh tokens; token expires in ~1h) |
22+
| `-a`<br>`--account`<br>`--acct` | `string` | | Account email, alias, or auto for authenticated Google API commands |
23+
| `--client` | `string` | | OAuth client name (selects stored credentials + token bucket) |
24+
| `--color` | `string` | auto | Color output: auto\|always\|never |
25+
| `--create-project` | `bool` | | Create --gcloud-project with gcloud (requires confirmation) |
26+
| `--credentials` | `string` | | Downloaded Desktop OAuth client JSON to store |
27+
| `--disable-commands` | `string` | | Comma-separated list of disabled commands; dot paths allowed |
28+
| `-n`<br>`--dry-run`<br>`--dryrun`<br>`--noop`<br>`--preview` | `bool` | | Do not make changes; print intended actions and exit successfully |
29+
| `--enable-apis` | `bool` | | Enable selected Google APIs with gcloud |
30+
| `--enable-commands` | `string` | | Comma-separated list of enabled command prefixes; dot paths allowed (restricts CLI) |
31+
| `--enable-commands-exact` | `string` | | Comma-separated list of exact enabled commands; dot paths allowed and parent commands do not enable children |
32+
| `-y`<br>`--force`<br>`--assume-yes`<br>`--yes` | `bool` | | Skip confirmations for destructive commands |
33+
| `--force-consent` | `bool` | | Force OAuth consent when --login runs |
34+
| `--gcloud-project`<br>`--project-id` | `string` | | Google Cloud project ID (default: active gcloud project) |
35+
| `--gmail-no-send` | `bool` | false | Block Gmail send operations (agent safety) |
36+
| `-h`<br>`--help` | `kong.helpFlag` | | Show context-sensitive help. |
37+
| `--home` | `string` | | Override gogcli config/data/state/cache root (equivalent to GOG_HOME) |
38+
| `-j`<br>`--json`<br>`--machine` | `bool` | false | Output JSON to stdout (best for scripting) |
39+
| `--login` | `bool` | | Run browser OAuth after project/client setup |
40+
| `--no-input`<br>`--non-interactive`<br>`--noninteractive` | `bool` | | Never prompt; fail instead (useful for CI) |
41+
| `--open-console` | `bool` | | Open the OAuth client page for the selected project |
42+
| `-p`<br>`--plain`<br>`--tsv` | `bool` | false | Output stable, parseable text to stdout (TSV; no colors) |
43+
| `--project-name` | `string` | gog CLI | Display name when creating a project |
44+
| `--readonly` | `bool` | | Use read-only OAuth scopes when --login runs |
45+
| `--results-only` | `bool` | | In JSON mode, emit only the primary result (drops envelope fields like nextPageToken) |
46+
| `--select`<br>`--pick`<br>`--project` | `string` | | In JSON mode, select comma-separated fields (best-effort; supports dot paths). Desire path: use --fields for most commands. |
47+
| `--services` | `string` | gmail,calendar,drive,docs,sheets,contacts | Services to configure: comma-separated gmail,calendar,chat,classroom,drive,driveactivity,drivelabels,docs,slides,contacts,tasks,sheets,people,forms,sites,meet,appscript,analytics,searchconsole,ads,youtube,photos |
48+
| `-v`<br>`--verbose` | `bool` | | Enable verbose logging |
49+
| `--version` | `kong.VersionFlag` | | Print version and exit |
50+
| `--wrap-untrusted` | `bool` | false | In JSON/raw output, wrap fetched text fields in external untrusted-content markers |
51+
52+
## See Also
53+
54+
- [gog auth](gog-auth.md)
55+
- [Command index](README.md)

docs/commands/gog-auth.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ gog auth <command> [flags]
2828
- [gog auth remove](gog-auth-remove.md) - Remove a stored refresh token
2929
- [gog auth service-account](gog-auth-service-account.md) - Configure service account (Workspace only; domain-wide delegation)
3030
- [gog auth services](gog-auth-services.md) - List supported auth services and scopes
31+
- [gog auth setup](gog-auth-setup.md) - Guide Google Cloud, OAuth client, and account setup
3132
- [gog auth status](gog-auth-status.md) - Show auth configuration and keyring backend
3233
- [gog auth tokens](gog-auth-tokens.md) - Manage stored refresh tokens
3334

docs/quickstart.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,23 @@ Other options (Docker, Windows ZIPs, source builds) are documented on
2121

2222
## 2. Get an OAuth client
2323

24+
For guided setup, inspect or execute the common `gcloud` path:
25+
26+
```bash
27+
gog auth setup [email protected] --gcloud-project my-gog-project --enable-apis --open-console
28+
```
29+
30+
Add `--create-project` to create that project after confirmation. After downloading the
31+
Desktop OAuth client JSON, one command can store it and start authorization:
32+
33+
```bash
34+
gog auth setup [email protected] --gcloud-project my-gog-project \
35+
--credentials ~/Downloads/client_secret_*.json --login
36+
```
37+
38+
Use `--dry-run --json --no-input` to inspect the complete plan without creating a project,
39+
enabling APIs, storing credentials, opening a browser, or starting OAuth.
40+
2441
`gog` talks to Google APIs as you, using your own Cloud project. The one-time
2542
setup is:
2643

internal/cmd/auth.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ const (
9090
)
9191

9292
type AuthCmd struct {
93+
Setup AuthSetupCmd `cmd:"" name:"setup" help:"Guide Google Cloud, OAuth client, and account setup"`
9394
Credentials AuthCredentialsCmd `cmd:"" name:"credentials" help:"Manage OAuth client credentials"`
9495
Add AuthAddCmd `cmd:"" name:"add" help:"Authorize and store a refresh token"`
9596
Import AuthImportCmd `cmd:"" name:"import" help:"Import a required refresh token and optional current access token non-interactively"`

0 commit comments

Comments
 (0)