# Credentials And Runtime Storage The Node runtime stores connections, OAuth client configuration, pending OAuth states, runtime tokens, recent run logs, and HTTP Action idempotency claims and responses in SQLite or PostgreSQL. The Cloudflare Workers runtime stores the same runtime records in D1 and temporary transit files in R2. By default the database lives at: ```text ./data/connect.sqlite ``` Set `OOMOL_CONNECT_DATA_DIR` to use another directory. The Docker image defaults this to `/app/data`, which is intended to be mounted as a volume. Set `OOMOL_CONNECT_DATABASE_URL` to use a PostgreSQL database instead; see [configuration](configuration.md#runtime-database). - `no_auth` providers are available as virtual connections and do not store secrets. - `api_key` and `custom_credential` providers store their local secrets in the selected runtime database. - `oauth2` providers use user-provided OAuth client configuration and a runtime callback URL. ## SaaS OAuth credentials A SaaS OAuth connection stores a remote account reference instead of a local OAuth credential. Provider tokens and app secrets remain on SaaS; Connect encrypts the project API key and sensitive authorization request data. Encryption and an explicit public origin are required before configuring a project. See [SaaS OAuth](saas-oauth.md) for configuration, execution boundaries and outage handling, and [maintenance](saas-maintenance.md) for backup restoration versus independent clone reset. ## Encryption Set `OOMOL_CONNECT_ENCRYPTION_KEY` to encrypt stored credentials, OAuth client configuration, pending OAuth state, and completed idempotent Action response payloads: ```bash OOMOL_CONNECT_ENCRYPTION_KEY="replace-with-a-long-random-secret" npm run dev ``` The runtime uses AES-256-GCM for provider credential records, OAuth client configuration, pending OAuth state, and the completed response payload retained for an idempotent HTTP Action retry. The raw `Idempotency-Key` is never stored; the database contains its hash and a request fingerprint. Claim identifiers, state, timestamps, and expiry are also stored as unencrypted metadata. The encryption key is not stored by OpenConnector; if it is lost, encrypted records cannot be recovered. Without `OOMOL_CONNECT_ENCRYPTION_KEY`, the runtime stays usable for local development and prints a startup warning. In that mode, credentials, OAuth client configuration, pending OAuth state, and completed idempotent Action responses are stored as plaintext. Action responses may contain sensitive provider data, so treat `connect.sqlite`, PostgreSQL, or D1 as a sensitive data store even after a response is no longer eligible for replay. Completed idempotent Action responses remain eligible for replay for 24 hours. Expired idempotency records are deleted opportunistically when a later idempotent Action request claims a key; the 24-hour replay window is not a guarantee of physical deletion by that deadline. ## Credential Fields Credential fields are declared by each provider's catalog `auth` metadata. The runtime treats that metadata as the contract for local API requests: - `api_key` connections always require `values.apiKey`. - `api_key` connections may declare additional `extraFields`. - `custom_credential` connections require exactly the provider-declared `fields`. - `oauth2` client config may declare additional `clientConfigFields`. All submitted string values are trimmed. Empty strings are treated as missing. Unknown submitted fields are rejected instead of being silently stored, because credential forms, scripts, and provider definitions should fail fast when they drift. Inspect a provider before writing setup scripts: ```bash curl -s http://localhost:3000/api/providers/github ``` ## Connection Identity When a provider can cheaply validate credentials against a current-user or current-account endpoint, its validator stores a stable connection profile: - `accountId`: provider-side user, workspace, bot, account, or token identifier. - `displayName`: human-readable account label. - `grantedScopes`: provider-native scopes granted to the credential, when known. The runtime exposes this profile in `/api/connections`, MCP action discovery, action agent guides, and recent run logs. Agents should use it to understand which account an action will run as; raw provider tokens are never exposed. An OAuth connection also carries `oauthAuthorizationId` in `/api/connections`: the `state` of the callback that completed its consent. It changes only when a new consent completes, never on token refresh, so a caller can tell a fresh grant from the credential it replaced. Connections made before this field existed omit it. Check current connections: ```bash curl -s http://localhost:3000/api/connections ``` ## API Key Connections Create or replace the default API key connection: ```bash curl -s -X PUT http://localhost:3000/api/connections/github \ -H 'content-type: application/json' \ -d '{"authType":"api_key","values":{"apiKey":"github_pat_..."}}' ``` Create or replace a named API key connection: ```bash curl -s -X PUT http://localhost:3000/api/connections/github \ -H 'content-type: application/json' \ -d '{"authType":"api_key","connectionName":"work","values":{"apiKey":"github_pat_..."}}' ``` The accepted keys are `apiKey` plus the provider's `auth[].extraFields`. Execute an action with the default connection: ```bash curl -s -X POST http://localhost:3000/v1/actions/github.get_current_user \ -H 'content-type: application/json' \ -d '{"input":{}}' ``` ## Custom Credential Connections Create or replace the default custom credential connection: ```bash curl -s -X PUT http://localhost:3000/api/connections/example \ -H 'content-type: application/json' \ -d '{"authType":"custom_credential","values":{"host":"localhost","password":"..."}}' ``` The accepted keys come from the provider's `auth[].fields`. ### MQTT connections MQTT requires a broker with a `ws://` or `wss://` listener. Raw `mqtt://` and `mqtts://` connections, client TLS certificates and custom certificate authorities are not supported. Private-network brokers require a self-hosted Node deployment with `OOMOL_CONNECT_ALLOW_PRIVATE_NETWORK` enabled; Cloudflare Workers cannot reach LAN brokers. The default protocol is MQTT 3.1.1. Set `protocolVersion` to `5.0` for MQTT 5; a failed handshake does not retry with a different version. Each action opens a new clean connection and closes it before returning, using a random Client ID unless `clientId` is configured. For Alibaba Cloud ApsaraMQ device authentication, configure `aliyunInstanceId` and a `clientId` in `GroupID@@@DeviceID` format. Supply both `aliyunDeviceAccessKeyId` and `aliyunDeviceAccessKeySecret` together, either in the saved connection or in each action. Other cloud-vendor signing schemes are not supported. `publish_message` accepts UTF-8 or base64 payloads, QoS 0, 1 or 2, and optional retain. `receive_messages` collects at most 100 messages over at most 30 seconds. It does not keep a background subscription or offline inbox; non-retained messages between calls are missed. The provider has no workflow trigger or generic HTTP proxy. ## OAuth2 Connections OAuth2 providers require your own provider OAuth app. List OAuth-capable providers and copy the `expectedRedirectUri` for the service: ```bash curl -s http://localhost:3000/api/oauth/configs ``` Paste that exact callback URL into the provider OAuth app. With the default port, GitHub uses: ```text http://localhost:3000/oauth/callback ``` If the browser reaches the runtime through another origin, set `OOMOL_CONNECT_ORIGIN` before starting the runtime: ```bash OOMOL_CONNECT_ORIGIN="https://your-tunnel.example" npm run dev ``` Then use the new `expectedRedirectUri` returned by `/api/oauth/configs`. Store the local client configuration: ```bash curl -s -X PUT http://localhost:3000/api/oauth/configs/github \ -H 'content-type: application/json' \ -d '{"clientId":"...","clientSecret":"..."}' ``` By default, authorization requests cover the provider's ordinary capabilities. A deployment that needs a smaller permission surface can save `requestedScopes` with the OAuth client configuration: ```bash curl -s -X PUT http://localhost:3000/api/oauth/configs/github \ -H 'content-type: application/json' \ -d '{"clientId":"...","clientSecret":"...","requestedScopes":["read:user"]}' ``` Omit `requestedScopes` to keep the provider defaults. An explicit array replaces them, including an empty array; the runtime adds only `requiredScopes` needed for connection validation or renewal. Unknown scopes are accepted and upstream APIs determine actual permissions. Config summaries expose both `requestedScopes` and the resulting `effectiveScopes`, which describe a future request, not a grant. The connection form displays only curated extra permissions, such as GitHub repository deletion. These options have localized labels and descriptions and extend the defaults when selected. Use advanced scope settings to replace the default request with your own list. Editing the same OAuth client's credentials in the console preserves its saved scope selection; replacing the client uses provider defaults. For Google Drive, configure the optional `drive.file` scope to access only files created by the app or explicitly selected/shared with the app by the user: ```bash curl -s -X PUT http://localhost:3000/api/oauth/configs/googledrive \ -H 'content-type: application/json' \ -d '{"clientId":"...","clientSecret":"...","requestedScopes":["https://www.googleapis.com/auth/drive.file"]}' ``` Start a new OAuth authorization after saving this configuration. Changing it does not narrow an existing token's grants; revoke existing broad access in Google before reconnecting if you need to verify a connection with only `drive.file`. Omitting `requestedScopes` retains the existing full Drive mode. Service Account and custom credential configuration are unchanged. The host application supplies the [Google Picker UI](https://developers.google.com/workspace/drive/api/guides/picker) and passes the selected file or folder ID to OpenConnector. Use the same Google Cloud project for Picker and the OAuth client. Selecting a folder does not grant access to all existing descendants. To upload a generated file into an authorized My Drive or Shared Drive folder, call `googledrive.files.create` with that folder ID in `parents` and the file content in `text` or `contentBase64`. Use `googledrive.files.get` to read an authorized file and `googledrive.files.update` to modify one. With `drive.file`, `googledrive.files.list` only returns files the app can access; it cannot enumerate the user's entire Drive or replace Picker for discovering files not yet authorized to the app. The scope also supports the existing `files.copy`, `files.delete`, `files.export`, `files.generateIds`, `files.listLabels`, and `files.modifyLabels` actions, subject to the user's file permissions. It does not support `files.emptyTrash` or all Shared Drive administration actions. Shared Drive inputs depend on the action: - `files.list` accepts `supportsAllDrives` and `includeItemsFromAllDrives`. - `files.get` accepts `includeSharedDrives` (defaults to `true`), which the connector maps to Google's `supportsAllDrives` parameter. - `files.create` and `files.update` enable Shared Drive support automatically and do not accept a `supportsAllDrives` input. These settings do not grant additional permissions. See [Google's Drive scope guide](https://developers.google.com/workspace/drive/api/guides/api-specific-auth) for the per-file access model. A provider whose OAuth app is registered with a different redirect URI, for example a native app's custom scheme, can save it as `redirectUri` with the client configuration: ```bash curl -s -X PUT http://localhost:3000/api/oauth/configs/example \ -H 'content-type: application/json' \ -d '{"clientId":"...","clientSecret":"...","redirectUri":"myapp://oauth/callback"}' ``` The value must be an absolute URI without user info or a fragment, and it is sent exactly as saved. Custom schemes are accepted; `javascript:`, `vbscript:`, `data:`, `file:`, `blob:`, and `about:` are rejected. The authorization request and the code exchange both send it, and `expectedRedirectUri` reports it so you can register that value with the provider. Omit it or send an empty string to use the runtime callback again; each `PUT` replaces the whole configuration, so include `redirectUri` whenever you save the configuration. The runtime's `/oauth/callback` route is unchanged: the app that owns the redirect forwards the provider's callback query (`code` and `state`, or `error`) to it. Other providers keep the runtime callback. Some providers declare additional OAuth client fields in `auth[].clientConfigFields`; send those as `extra`. Start authorization: ```bash curl -s -X POST http://localhost:3000/api/oauth/authorizations \ -H 'content-type: application/json' \ -d '{"service":"github"}' ``` Open the returned `authorizationUrl` in a browser. After the provider redirects to the local callback URL, the runtime stores the OAuth credential as the default connection. The console can start a connection-scoped OAuth flow with a custom app without changing the global config. Set `OOMOL_CONNECT_ALLOWED_CUSTOM_OAUTH` to `*` or a comma-separated provider list, and set `OOMOL_CONNECT_ENCRYPTION_KEY`. Then include `clientId` and, when required by the provider, `clientSecret` (plus provider-declared `extra` or `secretExtra` fields) in the existing OAuth authorization request: ```bash curl -s -X POST http://localhost:3000/api/oauth/authorizations \ -H 'content-type: application/json' \ -d '{"service":"github","connectionName":"work","clientId":"...","clientSecret":"..."}' ``` Connection-scoped OAuth client requests follow the same `requestedScopes` replacement and normalization rules: unknown scopes and explicit empty arrays are accepted, whitespace and duplicates are removed, and connection prerequisites are added automatically. The callback URL is still the deployment's `/oauth/callback` (for example, `https://connect.example.com/oauth/callback`), and the connection keeps the supplied app values for future token refreshes. Omitting all client fields continues to use the global config. To store the OAuth credential as a named connection, include `connectionName` when starting authorization: ```bash curl -s -X POST http://localhost:3000/api/oauth/authorizations \ -H 'content-type: application/json' \ -d '{"service":"github","connectionName":"work"}' ``` Protect the selected runtime database like any other store containing API keys or OAuth tokens. ## Selecting A Connection For Execution The default connection is used when no alias is provided: ```bash curl -s -X POST http://localhost:3000/v1/actions/github.get_current_user \ -H 'content-type: application/json' \ -d '{"input":{}}' ``` If a named connection already exists, select it with `x-oo-connector-alias`: ```bash curl -s -X POST http://localhost:3000/v1/actions/github.get_current_user \ -H 'x-oo-connector-alias: work' \ -H 'content-type: application/json' \ -d '{"input":{}}' ``` The `alias` query parameter is also accepted: ```bash curl -s -X POST "http://localhost:3000/v1/actions/github.get_current_user?alias=work" \ -H 'content-type: application/json' \ -d '{"input":{}}' ``` Persistent runtime tokens may further restrict this selection with `allowedConnections`. An omitted or empty list leaves every stored connection available. Entries are the stable, opaque IDs returned when connections are created or listed. The alias above selects the `work` connection, whose `id` must be granted; an unnamed request selects the default connection and requires its ID. Other connections return `403 connection_not_allowed` before the credential is loaded. Virtual `no_auth` connections do not require a grant. Example: keep a shared default GitHub connection and a `work` connection, then issue one unrestricted token and one work-only token: ```bash curl -s -X PUT http://localhost:3000/api/connections/github \ -H 'content-type: application/json' \ -d '{"authType":"api_key","values":{"apiKey":"github_pat_default"}}' curl -s -X PUT http://localhost:3000/api/connections/github \ -H 'content-type: application/json' \ -d '{"authType":"api_key","connectionName":"work","values":{"apiKey":"github_pat_work"}}' curl -s -X POST http://localhost:3000/api/runtime-tokens \ -H 'content-type: application/json' \ -d '{"name":"shared-client","allowedActions":[],"blockedActions":[],"allowedProxies":[]}' curl -s -X POST http://localhost:3000/api/runtime-tokens \ -H 'content-type: application/json' \ -d '{"name":"work-client","allowedActions":[],"blockedActions":[],"allowedProxies":[],"allowedConnections":[""]}' ``` ## Reset And Key Rotation Reset Node runtime data in the selected SQLite or PostgreSQL database: ```bash npm run runtime:data -- reset --yes ``` Rotate the Node runtime data-encryption key: ```bash OOMOL_CONNECT_ENCRYPTION_KEY="old-secret" \ OOMOL_CONNECT_NEW_ENCRYPTION_KEY="new-secret" \ npm run runtime:data -- rotate-key ``` Remove Node runtime data encryption only when you intentionally want plaintext storage: ```bash OOMOL_CONNECT_ENCRYPTION_KEY="old-secret" \ npm run runtime:data -- rotate-key --plain ``` For PostgreSQL, set `OOMOL_CONNECT_DATABASE_URL` on the reset or rotate command. The schema must already be initialized with `npm run runtime:migrate`. Key rotation re-encodes stored credentials, OAuth client configuration, pending OAuth state, and completed idempotent Action response payloads. Idempotency key hashes, request fingerprints, claim state, and timestamps remain unencrypted metadata. Pause all Node runtime instances before resetting data or rotating a PostgreSQL encryption key. `runtime:data` supports the Node SQLite and PostgreSQL backends. For Cloudflare, back up and restore D1/R2 directly with Cloudflare tooling. ## OAuth Token Refresh OAuth access tokens are refreshed automatically when they are expired and the provider issued a refresh token. Refreshed credentials are written back to the selected Node runtime database, using encryption when `OOMOL_CONNECT_ENCRYPTION_KEY` is configured. If a token is expired and no refresh token is available, reconnect the provider from the local runtime. Providers such as Google may require authorization parameters that request offline access; provider definitions should include those parameters when refresh tokens are expected. ## Local API Access The server binds to `127.0.0.1` by default. Set `HOST=0.0.0.0` only when the runtime must be reachable from outside the local machine or container. Set an admin bearer token when the admin API or web console is reachable outside your own shell: ```bash OOMOL_CONNECT_ADMIN_TOKEN="replace-with-an-admin-token" npm run dev ``` Admin clients calling `/api`, `/docs`, or the web console should send: ```text Authorization: Bearer replace-with-an-admin-token ``` Create runtime tokens for `/v1` and `/mcp` callers from the web console Access tab or `POST /api/runtime-tokens`. The token is shown once when created; only a hash is stored in the selected runtime database. Runtime clients should send `Authorization: Bearer oct_...`. Persistent tokens configure Action rules, provider proxy grants, and optional connection grants independently. Their `allowedProxies` list is empty by default, which denies `/v1/proxy/:service`; add a provider service or `*` only when that client needs proxy access. Omit `allowedConnections` or send `[]` on create for unrestricted connection access. Updates must send the field so a PUT cannot drop an existing restriction. A non-empty list is an exact allowlist of stable, opaque IDs returned by the connection APIs; unnamed requests select the provider's default connection and are denied unless its ID is listed. Virtual `no_auth` connections do not require a grant. HTTP, MCP, and proxy callers receive `connection_not_allowed` before lookup. Runtime discovery is filtered; `GET /api/connections` and Action `agent.md` guides are not. `OOMOL_CONNECT_RUNTIME_TOKEN` is still accepted for bootstrap scripts and backward compatibility. The bundled web console receives a same-site local cookie from the runtime so it can keep working when API-token authentication is enabled. ## Action Policy Use `OOMOL_CONNECT_ALLOWED_ACTIONS` to expose only selected actions to HTTP and MCP execution: ```bash OOMOL_CONNECT_ALLOWED_ACTIONS="hackernews.*,github.get_current_user" npm run dev ``` Use `OOMOL_CONNECT_BLOCKED_ACTIONS` to deny specific actions even when a broader allowlist includes them: ```bash OOMOL_CONNECT_ALLOWED_ACTIONS="github.*" \ OOMOL_CONNECT_BLOCKED_ACTIONS="github.delete_repository" \ npm run dev ``` Provider proxy requests use separate service-level policy variables because `/v1/proxy/:service` can reach provider API endpoints beyond the curated action catalog. Action policy and proxy policy are independent: the action variables never restrict proxies, and the proxy variables never restrict actions. At the deployment and runtime layers, every provider proxy is allowed until you restrict it: ```bash OOMOL_CONNECT_ALLOWED_PROXIES="github" npm run dev ``` Persistent runtime tokens must also grant the requested provider through their independent `allowedProxies` list. Token grants intersect with the deployment and runtime proxy policy and cannot widen it. An empty token proxy grant denies every provider proxy. Set `OOMOL_CONNECT_BLOCKED_PROXIES="*"` to disable `/v1/proxy/:service` entirely. Restrict both surfaces when you want both restricted: ```bash OOMOL_CONNECT_ALLOWED_ACTIONS="github.get_current_user" \ OOMOL_CONNECT_ALLOWED_PROXIES="github" \ npm run dev ``` Use `OOMOL_CONNECT_BLOCKED_PROXIES` to deny provider proxies even when `OOMOL_CONNECT_ALLOWED_PROXIES` contains `*`: ```bash OOMOL_CONNECT_ALLOWED_PROXIES="*" \ OOMOL_CONNECT_BLOCKED_PROXIES="github" \ npm run dev ``` Action policy entries are comma-separated action ids. A provider-wide wildcard such as `gmail.*` matches all actions for that provider, and a bare `*` matches every action. Proxy policy entries are comma-separated provider service names, or `*` for all provider proxies.