Google API

Google ID tokens use RS256 signatures. Verify them with the public keys at /oauth2/v3/certs, the instance issuer, your client ID, and the request nonce. Signing keys last for the server process; restarting it invalidates earlier tokens.

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)

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
  • GET /gmail/v1/users/:userId/profile - mailbox address, totals and current history id
  • POST /gmail/v1/users/:userId/watch - push notifications to the topic's Pub/Sub push subscriptions (expires after 7 days)
  • POST /gmail/v1/users/:userId/stop - stop push notifications

Gmail push: users.watch notifies the topic's Cloud Pub/Sub push subscriptions after a matching mailbox change (labelIds with INCLUDE or EXCLUDE), at most once a second per user, as Gmail does. Pub/Sub is not emulated, so configure push subscriptions with the pubsub_push_subscriptions seed field or POST /_emulate/google/pubsub/subscriptions:

google:
  pubsub_push_subscriptions:
    - name: projects/demo/subscriptions/gmail-push
      topic: projects/demo/topics/gmail
      push_endpoint: https://app.example.test/push
      audience: https://app.example.test/push

Each push is the Pub/Sub-wrapped body (message.data is base64 {"emailAddress","historyId"}, plus messageId, publishTime and subscription) with Authorization: Bearer <OIDC token>. The token is RS256, with aud (the audience, or the push endpoint), email (default gmail-push@{project}.iam.gserviceaccount.com), email_verified, sub, azp, iat and exp. Google signs with its own keys and iss https://accounts.google.com; the emulator signs with its OIDC key, so point the receiver's verifier at the emulator: JWKS <base>/oauth2/v3/certs and issuer <base>.

For a test the emulator cannot reach:

  • POST /_emulate/google/gmail/arrive with {"to":"user@example.com","from":"a@example.com","subject":"hi","text":"hello","headers":[{"name":"List-Id","value":"..."}]} delivers mail to the INBOX and notifies the watch.
  • POST /_emulate/google/gmail/preview-push with {"email":"user@example.com"} returns each push's URL, headers (with the signed token) and body without sending them.
  • GET /_emulate/google/pubsub/deliveries lists the pushes made and whether each was acknowledged (102, 200, 201, 202 or 204).

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 /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
  • DELETE /drive/v3/files/:fileId - delete a file or folder
  • POST /upload/drive/v3/files - upload file