Skip to content

Connection

Manages Google Cloud service account authentication.

ts
import { Connection } from "betterspread"

Constructor

ts
new Connection(opts: ConnectionOptions)

ConnectionOptions

PropertyTypeDescription
credentialsPathstringPath to service account JSON file
credentialsDictRecord<string, unknown>Inline service account credentials

Exactly one of credentialsPath or credentialsDict is required.

Methods

getSheetsClient()

ts
getSheetsClient(): Promise<sheets_v4.Sheets>

Returns authenticated Google Sheets API client.

getDriveClient()

ts
getDriveClient(): Promise<drive_v3.Drive>

Returns authenticated Google Drive API client (used for resolving spreadsheet names).