@emulators/google
v0.4.1
Published
Google OAuth 2.0, OpenID Connect, and mutable Google Workspace-style surfaces for local Gmail, Calendar, and Drive flows.
Readme
@emulators/google
Google OAuth 2.0, OpenID Connect, and mutable Google Workspace-style surfaces for local Gmail, Calendar, and Drive flows.
Part of emulate — local drop-in replacement services for CI and no-network sandboxes.
Install
npm install @emulators/googleEndpoints
OAuth & OIDC
GET /o/oauth2/v2/auth— authorization endpointPOST /oauth2/token— token exchangeGET /oauth2/v2/userinfo— get user infoGET /.well-known/openid-configuration— OIDC discovery documentGET /oauth2/v3/certs— JSON Web Key Set (JWKS)
Gmail
GET /gmail/v1/users/:userId/messages— list messages withq,labelIds,maxResults, andpageTokenGET /gmail/v1/users/:userId/messages/:id— fetch message infull,metadata,minimal, orrawformatsGET /gmail/v1/users/:userId/messages/:messageId/attachments/:id— fetch attachment bodiesPOST /gmail/v1/users/:userId/messages/send— create sent mail fromrawMIME or structured fieldsPOST /gmail/v1/users/:userId/messages/import— import inbox mailPOST /gmail/v1/users/:userId/messages— insert a message directlyPOST /gmail/v1/users/:userId/messages/:id/modify— add/remove labels on one messagePOST /gmail/v1/users/:userId/messages/batchModify— add/remove labels across many messagesPOST /gmail/v1/users/:userId/messages/:id/trash— trash messagePOST /gmail/v1/users/:userId/messages/:id/untrash— untrash message
Drafts
GET /gmail/v1/users/:userId/drafts— list draftsPOST /gmail/v1/users/:userId/drafts— create draftGET /gmail/v1/users/:userId/drafts/:id— get draftPUT /gmail/v1/users/:userId/drafts/:id— update draftPOST /gmail/v1/users/:userId/drafts/:id/send— send draftDELETE /gmail/v1/users/:userId/drafts/:id— delete draft
Threads
GET /gmail/v1/users/:userId/threads— list threadsGET /gmail/v1/users/:userId/threads/:id— get threadPOST /gmail/v1/users/:userId/threads/:id/modify— add/remove labels across a thread
Labels
GET /gmail/v1/users/:userId/labels— list labelsPOST /gmail/v1/users/:userId/labels— create labelPATCH /gmail/v1/users/:userId/labels/:id— update labelDELETE /gmail/v1/users/:userId/labels/:id— delete label
History, Watch & Settings
GET /gmail/v1/users/:userId/history— list historyPOST /gmail/v1/users/:userId/watch— set up push notificationsPOST /gmail/v1/users/:userId/stop— stop push notificationsGET /gmail/v1/users/:userId/settings/filters— list filtersPOST /gmail/v1/users/:userId/settings/filters— create filterDELETE /gmail/v1/users/:userId/settings/filters/:id— delete filterGET /gmail/v1/users/:userId/settings/forwardingAddresses— list forwarding addressesGET /gmail/v1/users/:userId/settings/sendAs— list send-as aliases
Calendar
GET /calendar/v3/users/:userId/calendarList— list calendarsGET /calendar/v3/calendars/:calendarId/events— list eventsPOST /calendar/v3/calendars/:calendarId/events— create eventDELETE /calendar/v3/calendars/:calendarId/events/:eventId— delete eventPOST /calendar/v3/freeBusy— free/busy query
Drive
GET /drive/v3/files— list filesGET /drive/v3/files/:fileId— get file metadataPOST /drive/v3/files— create filePATCH /drive/v3/files/:fileId— update file metadataPUT /drive/v3/files/:fileId— update file contentPOST /upload/drive/v3/files— upload file
Auth
Standard OAuth 2.0 authorization code flow. Configure clients in the seed config.
Seed Configuration
google:
users:
- email: [email protected]
name: Test User
oauth_clients:
- client_id: my-client-id.apps.googleusercontent.com
client_secret: GOCSPX-secret
redirect_uris:
- http://localhost:3000/api/auth/callback/google
labels:
- id: Label_ops
user_email: [email protected]
name: Ops/Review
messages:
- id: msg_welcome
user_email: [email protected]
from: [email protected]
to: [email protected]
subject: Welcome to the Gmail emulator
body_text: You can now test Gmail, Calendar, and Drive flows locally.
label_ids: [INBOX, UNREAD, CATEGORY_UPDATES]
calendars:
- id: primary
user_email: [email protected]
summary: [email protected]
primary: true
time_zone: UTC
calendar_events:
- id: evt_kickoff
user_email: [email protected]
calendar_id: primary
summary: Project Kickoff
start_date_time: 2025-01-10T09:00:00.000Z
end_date_time: 2025-01-10T09:30:00.000Z
drive_items:
- id: drv_docs
user_email: [email protected]
name: Docs
mime_type: application/vnd.google-apps.folder
parent_ids: [root]