Skip to content

Google Client

@theholocron/google-client is a typed wrapper around Google Workspace APIs for reading Google Docs and Sheets.

Terminal window
pnpm add @theholocron/google-client
import { google, googleAuth } from "@theholocron/google-client";
const auth = await googleAuth({
credentials: JSON.parse(process.env.GOOGLE_SERVICE_ACCOUNT_JSON),
scopes: ["https://www.googleapis.com/auth/documents.readonly"],
});
const doc = await google.documents.getDocument(auth, "document-id");
const sheet = await google.spreadsheets.getSpreadsheet(auth, "spreadsheet-id");
Namespace Covers
documents Google Docs documents
spreadsheets Google Sheets spreadsheets

This client does not use a token option. Instead it authenticates via a Google service account using googleAuth():

const auth = await googleAuth({
credentials: JSON.parse(process.env.GOOGLE_SERVICE_ACCOUNT_JSON),
scopes: [
"https://www.googleapis.com/auth/documents.readonly",
"https://www.googleapis.com/auth/spreadsheets.readonly",
],
});

The returned auth handle is passed as the first argument to every API call. Create a service account at Google Cloud Console → IAM & Admin → Service Accounts and download its JSON key. The oauth export provides the raw OAuth2 client for custom auth flows.

The full API reference is generated from the package’s TSDoc comments.