You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/content/docs/authoring/blocks/GoogleAuth.mdx
+42-8Lines changed: 42 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -49,8 +49,9 @@ Runbooks never shells out to the `gcloud` binary. Service account keys are valid
49
49
|`defaultZone`|`string`| — | Default compute zone for subsequent commands. Sets `CLOUDSDK_COMPUTE_ZONE` and `GOOGLE_ZONE`|
50
50
|`gcloudConfiguration`|`string`| — | Pre-select a named gcloud configuration in the gcloud Config tab (supports template expressions) |
51
51
|`scopes`|`string[]`|`cloud-platform`, `userinfo.email`, `openid`| OAuth scopes requested by Google Sign-In. When set, also **required** of any auto-detected or gcloud user ADC this block will accept (service-account keys are exempt) |
52
-
|`oauthClientId`|`string`| — | Client ID of a Google Cloud "Desktop app" OAuth client. **Required to enable the Google Sign-In tab** — this build ships no default client. Must be paired with `oauthClientSecret`|
52
+
|`oauthClientId`|`string`| — | Client ID of a Google Cloud "Desktop app" OAuth client. Must be paired with `oauthClientSecret`. Mutually exclusive with `oauthClientFile`. See [Using your own OAuth client](#using-your-own-oauth-client)|
53
53
|`oauthClientSecret`|`string`| — | Client secret issued alongside the Desktop OAuth client. Required whenever `oauthClientId` is set. Per RFC 8252 this value is not confidential; Google simply issues one with every Desktop client |
54
+
|`oauthClientFile`|`string`| — | Path to a Google Cloud Console Desktop-app client JSON download (`client_secret_*.json` with an `installed` object). `~` is expanded. Mutually exclusive with `oauthClientId` / `oauthClientSecret`. Read in the main process only |
54
55
|`detectCredentials`|`false \| GoogleCredentialSource[]`|`['env', 'adc']`| Whether and how to detect existing credentials. See [Credential Detection](#credential-detection)|
55
56
|`inputsId`|`string \| string[]`| — | Reference one or more [Inputs](/authoring/blocks/inputs/) blocks for template expressions in props |
56
57
@@ -194,7 +195,7 @@ A service account key is long-lived key material. Prefer **Google Sign-In** or t
194
195
## Google Sign-In
195
196
196
197
<Asidetype="caution">
197
-
**This tab currently requires an author-supplied OAuth client.** Runbooks does not yet ship a registered Google Cloud "Desktop app" client, so in a stock build the **Google Sign-In** tab renders disabled and labeled *(unavailable)*. Set both `oauthClientId` and `oauthClientSecret`(see [Using your own OAuth client](#using-your-own-oauth-client)) to enable it, or use the **Service Account Key** / **gcloud Config** tabs, which work out of the box.
198
+
**This tab currently requires an OAuth client.** Runbooks does not yet ship a registered Google Cloud "Desktop app" client, so in a stock build the **Google Sign-In** tab renders disabled and labeled *(unavailable)* unless you supply a client via props, a client JSON file, or operator environment variables (see [Using your own OAuth client](#using-your-own-oauth-client)). The **Service Account Key** / **gcloud Config** tabs work out of the box.
198
199
</Aside>
199
200
200
201
The **Google Sign-In** tab performs the same loopback OAuth flow as `gcloud auth application-default login`:
@@ -211,7 +212,7 @@ The requested scopes default to:
211
212
212
213
Override them with the `scopes` prop. The tab's **What permissions does this grant?** disclosure always lists exactly what will be requested.
213
214
214
-
When `scopes` is set, it is also a **requirement** for ambient credentials: auto-detected env/ADC credentials and the gcloud Config tab refuse a user credential whose tokeninfo grant is missing any listed scope. The block shows the missing scopes and offers **Sign in with required scopes** (or a copyable `gcloud auth application-default login --scopes=…` command when Sign-In is unavailable). Defaults are Sign-In request scopes only — they are **not** enforced on ambient ADC unless you set the prop.
215
+
When `scopes` is set, it is also a **requirement** for ambient credentials: auto-detected env/ADC credentials and the gcloud Config tab refuse a user credential whose tokeninfo grant is missing any listed scope. The block shows the missing scopes and offers **Sign in with required scopes** (or a copyable `gcloud auth application-default login --client-id-file="$GOOGLE_OAUTH_CLIENT_CREDENTIALS" --scopes=…` command when Sign-In still has no Desktop client). Defaults are Sign-In request scopes only — they are **not** enforced on ambient ADC unless you set the prop.
215
216
216
217
```mdx
217
218
<GoogleAuth
@@ -230,7 +231,15 @@ Because the flow returns a refresh token — not a bare access token — the cre
230
231
231
232
### Using your own OAuth client
232
233
233
-
Sign-in requires a registered Google Cloud **Desktop app** OAuth client, and today that means one of your own. Set **both**`oauthClientId` and `oauthClientSecret` to use your organization's client and consent screen:
234
+
Sign-in requires a registered Google Cloud **Desktop app** OAuth client. Until Runbooks ships a built-in client, supply one of your own. Resolution order in the main process:
@@ -242,8 +251,31 @@ Sign-in requires a registered Google Cloud **Desktop app** OAuth client, and tod
242
251
243
252
Both props are required together. `oauthClientId` on its own is refused with an explicit error rather than started: Google issues a client secret with every Desktop client, and without it the resulting user-credentials file cannot be refreshed — every later `gcloud`, client-library, and OpenTofu call would fail at the first token refresh, long after the block reported success.
244
253
254
+
**Client JSON file** (the Desktop-app download from Google Cloud Console — `{ "installed": { "client_id", "client_secret", … } }`):
`oauthClientFile` is mutually exclusive with `oauthClientId` / `oauthClientSecret`. The path is read in the main process only (`~` is expanded); the secret never enters the UI. Web-client downloads (`{ "web": … }`) are rejected — Sign-In uses a loopback redirect registered for Desktop clients.
264
+
265
+
**Operator environment** (machine-local, no runbook change required):
266
+
267
+
| Variable | Value |
268
+
|----------|-------|
269
+
|`GOOGLE_OAUTH_CLIENT_CREDENTIALS`| Absolute or `~/…` path to a Desktop-app `client_secret_*.json`|
270
+
|`GOOGLE_OAUTH_CLIENT_ID`| Desktop-app client ID (must be paired with the secret) |
These are distinct from `GOOGLE_APPLICATION_CREDENTIALS`, which holds *user* or service-account credentials after authentication — not the OAuth app client used to start Sign-In.
274
+
275
+
**In-session file picker:** when no client is configured yet, the **Google Sign-In** tab stays selectable and labeled *(needs OAuth client)*. The panel offers **Choose Desktop OAuth client JSON** — the same Console download as `oauthClientFile` / `GOOGLE_OAUTH_CLIENT_CREDENTIALS`. The renderer keeps the path only; MAIN reads `installed.client_id` / `installed.client_secret` at sign-in start.
276
+
245
277
<Asidetype="caution">
246
-
If no OAuth client is configured — neither by the build nor by these props — the **Google Sign-In** tab is shown but disabled and labeled *(unavailable)* from the moment the block renders, with the message *"OAuth login is not configured for this build."* Use the **Service Account Key**or**gcloud Config**tab, or supply `oauthClientId` and `oauthClientSecret`.
278
+
If no OAuth client is configured — neither by the build, author props/file, operator env, nor an in-session pick — Sign-In cannot start until the operator supplies a Desktop client. Use the picker, set `GOOGLE_OAUTH_CLIENT_CREDENTIALS`, or fall back to the **Service Account Key**/**gcloud Config**tabs.
247
279
</Aside>
248
280
249
281
## gcloud Config
@@ -503,15 +535,17 @@ If a federated configuration you rely on is refused, authenticate with a service
503
535
504
536
| Symptom | Cause and fix |
505
537
|---------|---------------|
506
-
|**Google Sign-In** tab is greyed out and labeled *(unavailable)*| No OAuth client is configured for this build — the current default. Supply **both**`oauthClientId` and `oauthClientSecret`, or use the Service Account Key or gcloud Config tab |
538
+
|**Google Sign-In** tab labeled *(needs OAuth client)*| No OAuth client is configured yet (build default, author props/file, or `GOOGLE_OAUTH_CLIENT_*` env). Choose a Desktop client JSON in the panel, set env, or use the Service Account Key / gcloud Config tab |
507
539
|*"oauthClientId was supplied without oauthClientSecret"*| A custom Desktop client needs both. Google issues a secret with every Desktop client; without it the credential cannot be refreshed |
540
+
|*"Supply either oauthClientId/oauthClientSecret or oauthClientFile"*| Those props are mutually exclusive — pick one supply path |
541
+
|*"OAuth client credentials file is a Web client"*| Download a **Desktop app** client JSON from Google Cloud Console (`installed`), not a Web client (`web`) |
508
542
|*No gcloud configurations found*| There is no gcloud configuration directory at the reported path. Run `gcloud init`, or set `CLOUDSDK_CONFIG` to the directory you use |
509
543
| A configuration shows **No ADC** and cannot be selected | The configuration has no Application Default Credentials. Run `gcloud auth application-default login`|
510
544
|*Not a service account key (expected type: service_account)*| The pasted JSON is user credentials or an OAuth client file, not a service account key. Use the file that Google Cloud produced from **IAM & Admin → Service Accounts → Keys**|
511
545
|*…which Runbooks does not accept* / *…is not a Google API endpoint*| The credentials document is a workload identity federation config that fetches its subject token from a file, a URL, or a command, or that points at a host outside `*.googleapis.com`. Runbooks does not run those instructions. Use a service account key, **Sign in with Google**, or `gcloud auth application-default login`|
512
546
|*Invalid credentials detected: … are invalid or expired*| The detected credential no longer authenticates. Refresh it (`gcloud auth application-default login`) or authenticate manually |
513
-
|*Credentials missing required scopes*| The block's `scopes` prop lists scopes the detected user ADC does not grant (for example Admin SDK scopes). Use **Sign in with required scopes**, or run the shown `gcloud auth application-default login --scopes=…` command and try auto-detection again |
514
-
| gcloud Config / confirm fails with *missing required OAuth scopes*| Same check as detection: the selected ADC is too narrow for this block. Re-authenticate with the required scopes via Sign-In or `gcloud auth application-default login --scopes=…`|
547
+
|*Credentials missing required scopes*| The block's `scopes` prop lists scopes the detected user ADC does not grant (for example Admin SDK scopes). Use **Sign in with required scopes**, or run the shown `gcloud auth application-default login --client-id-file="$GOOGLE_OAUTH_CLIENT_CREDENTIALS" --scopes=…` command and try auto-detection again |
548
+
| gcloud Config / confirm fails with *missing required OAuth scopes*| Same check as detection: the selected ADC is too narrow for this block. Re-authenticate with the required scopes via Sign-In or `gcloud auth application-default login --client-id-file=… --scopes=…`|
515
549
| The project picker is empty | The credential cannot list projects. Grant `resourcemanager.projects.list`, or set the `project` prop / type the project ID directly |
516
550
|*Project … is not accessible with these credentials*| Advisory warning: the credential authenticated, but Google definitively refused (404/permission denied) on that project. Check the project ID and the principal's IAM roles. An inconclusive answer — a disabled Cloud Resource Manager API, a network blip — deliberately produces **no** warning, because it says nothing about whether your commands will work |
517
551
|*Authenticated, but no Google Cloud project is set*| The credential is valid but nothing named a project: no `project` prop, no `core/project` in the gcloud configuration, and no project the principal can enumerate. Commands that need one will fail with *"The project property must be set"*. Set the `project` prop, run `gcloud config set project`, or use **Change project**|
return{error: "OAuth login is not configured for this build"}
743
-
}
744
-
// A Desktop client without its secret cannot be refreshed: the exchange
745
-
// may succeed, but the authorized_user document written from it would
746
-
// carry client_secret:"" and every later refresh — gcloud, the client
747
-
// libraries, the OpenTofu provider — would fail. Refuse up front rather
748
-
// than publish a credential that only looks authenticated.
749
-
if(!clientSecret){
750
-
return{
751
-
error:
752
-
"oauthClientId was supplied without oauthClientSecret. Google issues a client secret with every Desktop app client; the credential cannot be refreshed without it.",
0 commit comments