> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mirage.strukto.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Google Docs

> Mount Google Docs as JSON-backed files from Node or the browser.

`GDocsResource` exposes Google Docs as `.gdoc.json` files. Reads return the document's structured content; writes update the doc in place via the Google Docs API.

Setup steps for OAuth credentials live at [Google Workspace Credentials](/home/setup/google).

## Node

```bash theme={null}
pnpm add @struktoai/mirage-node
```

```ts theme={null}
import { GDocsResource, MountMode, Workspace } from '@struktoai/mirage-node'

const docs = new GDocsResource({
  clientId: process.env.GOOGLE_CLIENT_ID!,
  clientSecret: process.env.GOOGLE_CLIENT_SECRET!,
  refreshToken: process.env.GOOGLE_REFRESH_TOKEN!,
})

const ws = new Workspace({ '/docs': docs }, { mode: MountMode.WRITE })
await ws.execute('cat /docs/owned/MyDoc.gdoc.json')
```

## Browser

```bash theme={null}
pnpm add @struktoai/mirage-browser
```

```ts theme={null}
import { GDocsResource, MountMode, Workspace } from '@struktoai/mirage-browser'

const docs = new GDocsResource({
  clientId: GOOGLE_CLIENT_ID,
  clientSecret: GOOGLE_CLIENT_SECRET,
  refreshToken: localStorage.getItem('gdocs.refresh_token')!,
})

const ws = new Workspace({ '/docs': docs }, { mode: MountMode.WRITE })
```

A PKCE example lives at `examples/typescript/browser/src/gdocs_pkce.ts`.

## Config

| Field          | Default  | Notes                                                    |
| -------------- | -------- | -------------------------------------------------------- |
| `clientId`     | required | Google OAuth client ID.                                  |
| `clientSecret` | required | Google OAuth client secret. Redacted in snapshots.       |
| `refreshToken` | required | User's refresh token. Redacted in snapshots.             |
| `refreshFn`    | built-in | Optional override for the access-token refresh callback. |

## Mount mode

`read`, partial write (text replacements via the Docs API).

For the JSON shape and supported edits see the [Python Google Docs docs](/python/resource/gdocs).
