@homeslate/google
v0.1.3
Published
Google OAuth token exchange/refresh plus Calendar and Photos API helpers. Runtime-agnostic: you supply a `TokenStore`.
Readme
@homeslate/google
Google OAuth token exchange/refresh plus Calendar and Photos API helpers. Runtime-agnostic: you supply a TokenStore.
Install
pnpm add @homeslate/googleUsage
import { createGoogleClient } from "@homeslate/google";
import { FileTokenStore } from "@homeslate/adapters";
const google = createGoogleClient({
clientId: process.env.GOOGLE_CLIENT_ID!,
clientSecret: process.env.GOOGLE_CLIENT_SECRET!,
tokenStore: new FileTokenStore({ dir: "./data/tokens" }),
});
await google.exchangeAuthCode(accountId, code, redirectUri);
const calendars = await google.listCalendars(accountId);createGoogleClient throws if credentials are empty. Token refresh failures surface as GoogleAuthError (missing_tokens, invalid_grant, token_revoked, refresh_failed); narrow with isGoogleAuthError.
The host owns OAuth URLs and cookies. See the reference server.
Also exported
GoogleBindingStore— map a display to an account id (SqliteGoogleBindingStorein@homeslate/adapters)listCalendarsWithAccessToken/listEventsWithAccessToken/fetchPhotoWithAccessTokenwhen you already have a token
See also
@homeslate/adapters—FileTokenStoreand sqlite bindings@homeslate/widgets—GoogleRuntimeProviderfor the UI
