# Handoff: Bearer Auth Fix — 2026-06-17 ## Problem ChatGPT GPT Actions (Communications Manager, Living Brief) send `Authorization: Bearer ` per the OpenAPI `bearerAuth` spec. The Express auth middleware only accepted keys via `x-api-key` header or `?key=` query param — Bearer was not checked, so every GPT Action call returned 401. ## Commit `6ca0ca6` — fix(auth): accept customer API key via Authorization: Bearer header ## Changes ### src/index.ts — requireAuth middleware Added `bearerValue = extractBearerToken(req)` (function already existed) and included it as a third fallback in the `apiKeyProvided` expression: ```ts // Before const apiKeyProvided = req.headers['x-api-key'] || req.query.key; // After const bearerValue = extractBearerToken(req); const apiKeyProvided = req.headers['x-api-key'] || req.query.key || bearerValue; ``` All communications, obsidian, email, and MCP routes use requireAuth. ### src/billing/middleware.ts — meterMiddleware Same pattern, inlined since extractBearerToken lives in index.ts: ```ts // Before const apiKey = req.headers['x-api-key'] || req.query.key; // After const authHeader = req.headers.authorization; const bearerValue = authHeader?.startsWith('Bearer ') ? authHeader.slice(7) : undefined; const apiKey = req.headers['x-api-key'] || req.query.key || bearerValue; ``` Connection, webhook, and health routes use meterMiddleware. ## Auth flow after the fix 1. Extract bearer value from `Authorization: Bearer ` 2. Try as API key: `resolveCustomerByApiKey(bearerValue)` — succeeds if it matches a customer row in the DB 3. If no match (OAuth token, not API key): falls through to the existing OAuth access token validation — no regression ## Deploy instructions for kimi-cli Only hermes-mcp needs rebuilding (no frontend changes). ``` cd /path/to/hermes-mcp SHA=6ca0ca6 docker build -t localhost:32000/hermes-mcp:$SHA . docker save localhost:32000/hermes-mcp:$SHA | microk8s ctr image import - # OR: docker push localhost:32000/hermes-mcp:$SHA # Edit hermes-k8s.yaml image tag to $SHA — do NOT commit microk8s kubectl apply -f hermes-k8s.yaml microk8s kubectl rollout status deployment/hermes-mcp -n fetcherpay ``` ## Verification after deploy Get the API key from the API Keys tab at https://app.squaremcp.com, then: ```bash curl -H "Authorization: Bearer " https://hermes.squaremcp.com/api/auth/me # Should return: {"id":"...","email":"...","plan":"...","api_key":"..."} ``` If that returns 200, the Communications Manager GPT will authenticate.