---
title: "Google API"
description: "Local drop-in replacement services for CI and no-network sandboxes. Fully stateful, production-fidelity API emulation."
canonical_url: "https://emulate.dev/docs/google"
---
# Google API

OAuth 2.0, OpenID Connect, and mutable Google Workspace-style surfaces for local inbox, calendar, and drive flows.

## OAuth & OpenID Connect

- `GET /o/oauth2/v2/auth` - authorization endpoint
- `POST /oauth2/token` - token exchange
- `GET /oauth2/v2/userinfo` - get user info
- `GET /.well-known/openid-configuration` - OIDC discovery document
- `GET /oauth2/v3/certs` - JSON Web Key Set (JWKS) with the RSA public key for ID token verification

Google ID tokens are RS256-signed JWTs. The discovery document advertises RS256, and the JWKS endpoint returns the matching RSA public key used to verify issued tokens.

Google authentication is permissive by default for local bearer-token workflows. Set `google.strict_scopes: true` in seed config to require emulator-issued, unexpired access tokens on Gmail, Calendar, Drive, and userinfo routes. Invalid credentials return `401 UNAUTHENTICATED`; missing method scopes return `403` with `insufficientPermissions`. Strict mode distinguishes read, write, send, settings, and metadata scopes, and userinfo includes only granted identity claims. Revoking an access or refresh token invalidates the linked access and refresh credentials. Discovery, signing keys, and the sign-in page remain public. This mode checks method scopes; resource-specific grants such as `drive.file` and Gmail add-on scopes are not modeled.

## Gmail

- `GET /gmail/v1/users/:userId/messages` - list messages (`q`, `labelIds`, `maxResults`, `pageToken`)
- `GET /gmail/v1/users/:userId/messages/:id` - get message (`full`, `metadata`, `minimal`, `raw` formats)
- `GET /gmail/v1/users/:userId/messages/:messageId/attachments/:id` - get attachment
- `POST /gmail/v1/users/:userId/messages/send` - send message (raw MIME or structured fields)
- `POST /gmail/v1/users/:userId/messages/import` - import inbox mail
- `POST /gmail/v1/users/:userId/messages` - insert a message directly
- `POST /gmail/v1/users/:userId/messages/:id/modify` - add/remove labels
- `POST /gmail/v1/users/:userId/messages/batchModify` - batch label changes
- `POST /gmail/v1/users/:userId/messages/:id/trash` - trash message
- `POST /gmail/v1/users/:userId/messages/:id/untrash` - untrash message

## Gmail Drafts

- `GET /gmail/v1/users/:userId/drafts` - list drafts
- `POST /gmail/v1/users/:userId/drafts` - create draft
- `GET /gmail/v1/users/:userId/drafts/:id` - get draft
- `PUT /gmail/v1/users/:userId/drafts/:id` - update draft
- `POST /gmail/v1/users/:userId/drafts/:id/send` - send draft
- `DELETE /gmail/v1/users/:userId/drafts/:id` - delete draft

## Gmail Threads

- `GET /gmail/v1/users/:userId/threads` - list threads
- `GET /gmail/v1/users/:userId/threads/:id` - get thread
- `POST /gmail/v1/users/:userId/threads/:id/modify` - add/remove labels across a thread

## Gmail Labels

- `GET /gmail/v1/users/:userId/labels` - list labels
- `POST /gmail/v1/users/:userId/labels` - create label
- `PATCH /gmail/v1/users/:userId/labels/:id` - update label
- `DELETE /gmail/v1/users/:userId/labels/:id` - delete label

## Gmail History & Push

- `GET /gmail/v1/users/:userId/history` - list history changes
- `POST /gmail/v1/users/:userId/watch` - set up push notifications
- `POST /gmail/v1/users/:userId/stop` - stop push notifications

## Gmail Settings

- `GET /gmail/v1/users/:userId/settings/filters` - list filters
- `POST /gmail/v1/users/:userId/settings/filters` - create filter
- `DELETE /gmail/v1/users/:userId/settings/filters/:id` - delete filter
- `GET /gmail/v1/users/:userId/settings/forwardingAddresses` - list forwarding addresses
- `GET /gmail/v1/users/:userId/settings/sendAs` - list send-as aliases

## Calendar

- `GET /discovery/v1/apis/calendar/v3/rest` - public Calendar v3 REST discovery document
- `GET /calendar/v3/users/:userId/calendarList` - list calendars
- `GET /calendar/v3/calendars/:calendarId/events` - list events
- `POST /calendar/v3/calendars/:calendarId/events` - create event
- `DELETE /calendar/v3/calendars/:calendarId/events/:eventId` - delete event
- `POST /calendar/v3/freeBusy` - query free/busy

## Drive

- `GET /drive/v3/files` - list files
- `GET /drive/v3/files/:fileId` - get file metadata
- `POST /drive/v3/files` - create file metadata
- `PATCH /drive/v3/files/:fileId` - update file metadata
- `PUT /drive/v3/files/:fileId` - update file content
- `POST /upload/drive/v3/files` - upload file
