Your own OAuth broker
Google takes no client registered on the fly, so a Google Calendar account is connected through an OAuth broker: a small service that holds one Google OAuth client and keeps no token. The instance keeps the refresh token, sealed so that only its broker can open it; the broker adds the client secret when the instance refreshes. Without a broker, the Google Calendar plugin is listed as not configured and no Google Calendar account can be connected (Google offers no other way, CalDAV included).
A self-hosted instance runs its own broker from the same repository (apps/oauth-broker, image ghcr.io/vaubaan/oauth-broker). The full procedure, including the attested variant in Google Confidential Space, is in the broker handbook; here is the short path, without an enclave.
What you need
- A host that ends TLS for one public name, e.g.
https://broker.example.com, and runs a container (any Docker host behind a reverse proxy, Fly, Railway…). One machine: flows in progress live in its memory. - A Google Cloud project where you can create an OAuth client and enable the Calendar API.
Steps
-
The Google client. In the project: enable the Google Calendar API; on the consent screen, an external app with the scopes the broker may ask (
openid,email,https://www.googleapis.com/auth/calendar.calendarlist.readonly,https://www.googleapis.com/auth/calendar.events); then an OAuth client of type Web application whose redirect URI ishttps://broker.example.com/oauth/callback/google. Keep the client id; paste the client secret straight into the next step, no copy kept. -
Two secrets in the host's secret store, never in a file or the configuration:
OAUTH_BROKER_SECRET_GOOGLE_CLIENT_SECRET: the client secret;OAUTH_BROKER_SECRET_REFRESH_TOKEN_SEALING_KEY:openssl rand -base64 32. Never change it while an instance is enrolled: every token that instance holds would stop opening.
-
Enrol your instance. Draw its key and an opaque id, and keep their digests:
key="bk_$(openssl rand -base64 32 | tr '+/' '-_' | tr -d '=')" id="i_$(openssl rand -hex 6)" printf %s "$key" | sha256sum # key_sha256 printf %s "https://gateway.example.com/connections/callback/google-calendar" | sha256sum # return_url_sha256The return URL is your instance's
public_urlfollowed by/connections/callback/google-calendar, hashed exactly as written. -
Run the broker with
OAUTH_BROKER_PLATFORM=unattestedandOAUTH_BROKER_CONFIG, one JSON document of digests only:{ "public_url": "https://broker.example.com", "http_port": 8080, "providers": { "google": { "client_id": "123-abc.apps.googleusercontent.com" } }, "instances": [{ "id": "i_3f9a1c7e2b4d", "key_sha256": "…", "return_url_sha256": ["…"] }], "refresh_per_hour": 600 }Take the image by digest from the broker releases. One listener on
http_portserves the API, Google's callback and/healthzin plain HTTP; route the host's TLS front to it.refresh_per_hour(600 unless set) caps the refreshes of each instance. Its log readsstartedwithattested: false. -
Point the instance at it, in its configuration or environment, then restart it:
oauth_brokers: google: url: https://broker.example.com key: ${file:/run/secrets/oauth-broker-key} attestation: none(
VAUBAAN_OAUTH_BROKER_GOOGLE_URL,…_KEY_FILE,…_ATTESTATION=nonein the environment.)attestation: nonesays the broker runs without an enclave; the connect page then says "not attested". -
Check: Accounts → Connect an account → Google Calendar sends you to Google and back, and the account's calendars appear.
What it costs you
Whoever operates the broker's host can read the client secret and the sealing key, and could run other code in the image's place, seeing each access token that passes. On your own host that person is you. To remove that trust, run the same image in Google Confidential Space and enrol it with attestation: required (handbook): the instances then check what code runs before they send anything.
Adding an instance or changing the configuration is a restart of the broker: sign-ins in progress (ten minutes at most) are lost, never a token.
Last changed 2026-11-25. This page as Markdown: /docs/operations/oauth-broker.md