2026 OpenClaw with Feishu / Lark and Microsoft Teams: Reproducible Auth, Long Connections & Enterprise Egress on a ZoneMac Remote Physical Mac Gateway (openclaw.json Snippets + 401/429 FAQ)
Platform teams in China–global split footprints need OpenClaw to talk to Feishu (飞书), Lark international, and Microsoft Teams without tripping conditional access, stale tokens, or proxy idle cuts. This runbook explains who breaks where, compares transport and egress patterns, gives seven copy-pasteable deployment steps on a ZoneMac-style remote physical Mac, includes an illustrative openclaw.json fragment, cite-ready limits, and a 401/429 FAQ aligned with structured data.
Introduction
When OpenClaw sits on a headless remote Mac, Feishu and Lark expect stable callback verification and app credentials scoped to the right tenant, while Teams and Microsoft Graph add OAuth2 flows, national-cloud endpoints, and aggressive throttling. Security teams meanwhile publish egress allowlists and TLS-inspecting proxies that look identical to "random 401 day" until you correlate JWT expiry, SNAT IP, and proxy idle timers.
This guide assumes a single dedicated gateway process (or small HA pair) on a ZoneMac-class physical Mac in the region where your users actually chat, not on a developer laptop that sleeps when the lid closes. For clients that must use Windows or Linux desktops but still centralize trust on macOS, pair this article with OpenClaw on Windows and Linux with a remote macOS gateway.
A Chinese-language walkthrough of the same topic lives at the 简体中文版 Feishu / Lark / Teams 网关 Runbook (hreflang linked in <head>).
1. Pain points enterprises actually hit
- Split-tenant identity: Feishu domestic vs Lark global vs Entra ID for Teams rarely share the same app directory. A credential that works in a sandbox tenant fails in production with opaque 401s until you align authority URLs and verification secrets.
- Egress allowlists and SNAT drift: Vendors pin your outbound IP for webhooks or rate policies. Remote Mac pools that rotate egress without updating IT tickets cause sudden verification failures and duplicate event retries.
- Long-lived sessions vs proxy idle cuts: Bot SDKs keep WebSockets or chunked HTTP alive; corporate forward proxies often drop quiet flows between roughly five and fifteen minutes unless keepalives and PAC-aware routing are tuned.
- Audit and least privilege: Each platform wants different scopes—Graph
ChannelMessage.Read.Allvs Larkim:messagefamily vs Feishu event subscriptions. Over-scoped tokens fail security review; under-scoped tokens fail at runtime with 403/404 noise.
2. Decision matrix: where to terminate trust
Use this table when arguing for a stationary Mac gateway versus splitting bots per region.
| Dimension | Single remote Mac gateway | Per-region split bots |
|---|---|---|
| Egress IP stability | One SNAT ticket for NetOps | Multiple allowlists; drift risk |
| Long-lived connections | Easier keepalive tuning on wired host | More moving parts; consistent PAC needed |
| Blast radius on compromise | All channels share process memory | Smaller per-tenant secrets |
| 429 / quota isolation | One noisy loop can starve others | Separate app registrations |
| Ops complexity | One launchd unit, one log tail | N× deploy pipelines |
3. Seven-step reproducible runbook (ZoneMac remote physical Mac)
- Freeze the endpoint inventory: Enumerate
*.feishu.cn,open.feishu.cn, Lark open-platform hosts for your shard,login.microsoftonline.com,graph.microsoft.com(or Gov/GCCH equivalents), and any Teams bot connector URLs. Submit one change ticket with test commands. - Pin the Mac on wired power: Disable sleep for the gateway user, enforce NTP, and record the egress IP your vendor will see after NAT.
- Bind OpenClaw to loopback: Terminate TLS on nginx/Envoy or your Zero Trust tunnel; forward to
127.0.0.1:18789(or your chosen port) so scanners never hit the raw listener. - Inject secrets without GUI: Use SecretRef, launchd
EnvironmentVariables, or macOS Keychain-backed scripts—never commit tenant app secrets besideopenclaw.json. - Complete vendor challenges from production path: Register Feishu/Lark event URLs and Teams messaging endpoints using the same DNS, certificate, and proxy chain users will hit.
- Smoke-test auth and throttles: Script a Graph
/meor channel read with the same token class OpenClaw uses; send a Lark/Feishu test event and confirm signature headers. - Observe and game-day: Ship counters for 401/403/429 and reconnect reasons; after baseline, see Prometheus and Grafana on the OpenClaw gateway, then kill the local proxy and verify automatic recovery within your SLO window.
4. openclaw.json snippets (illustrative)
Replace placeholder keys with your vendor documentation; structure only shows how to keep channels side by side on one gateway host.
{
"gateway": {
"bind": "127.0.0.1:18789",
"publicBaseUrl": "https://openclaw-gateway.corp.example",
"logFormat": "jsonl"
},
"channels": {
"feishu": {
"appId": "${FEISHU_APP_ID}",
"appSecret": "${FEISHU_APP_SECRET}",
"encryptKey": "${FEISHU_ENCRYPT_KEY}",
"verificationToken": "${FEISHU_VERIFICATION_TOKEN}"
},
"lark": {
"appId": "${LARK_APP_ID}",
"appSecret": "${LARK_APP_SECRET}",
"encryptKey": "${LARK_ENCRYPT_KEY}"
},
"teams": {
"tenantId": "${ENTRA_TENANT_ID}",
"clientId": "${TEAMS_BOT_APP_ID}",
"clientSecret": "${TEAMS_BOT_SECRET}",
"graphAudience": "https://graph.microsoft.com/"
}
},
"httpClient": {
"proxyUrl": "${CORP_HTTPS_PROXY}",
"respectRetryAfter": true,
"maxConcurrentGraphRequests": 4
}
}
If your security team forbids a global HTTP_PROXY, split per-channel proxy settings where OpenClaw supports it, or route everything through an explicit forward proxy VM in the same region as the Mac.
4.1 nginx TLS front forwarding to localhost
server {
listen 443 ssl;
server_name openclaw-gateway.corp.example;
ssl_certificate /etc/ssl/internal/fullchain.pem;
ssl_certificate_key /etc/ssl/internal/privkey.pem;
location /feishu/events {
proxy_pass http://127.0.0.1:18789/feishu/events;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 120s;
}
location /teams/api/messages {
proxy_pass http://127.0.0.1:18789/teams/api/messages;
proxy_set_header Host $host;
proxy_read_timeout 120s;
}
}
5. Cite-ready parameters for design notes
- JWT clock skew: Plan for Entra-issued tokens to tolerate roughly ±300 seconds skew between the Mac and authoritative time; beyond that, Graph returns 401 even with a "valid" secret.
- 429 handling: Honor
Retry-Afterwhen Graph returns 429; default exponential backoff often starts near 1–2 seconds base with full jitter for fan-out workloads. - Proxy idle window: Many corporate forward proxies terminate quiet TLS flows between 300s and 900s; keepalive pings should fire well below the minimum observed idle timeout in packet captures.
6. FAQ: HTTP 401 and 429 triage
6.1 Microsoft Graph 401
Verify tenant ID in the token request URL, confirm the bot uses the correct national cloud host, re-run admin consent after scope changes, and check conditional access exclusions for the service principal. Compare iat/exp claims with sntp -sS time.apple.com on the Mac.
6.2 Graph or open platform 429
Reduce parallel channel sync jobs, cache directory IDs, avoid tight polling where webhooks exist, and split read-heavy cron tasks across minutes. If multiple products share one app registration, consider isolating Teams traffic so marketing experiments cannot starve CI notifications.
6.3 Feishu / Lark verification failures
Rotate encrypt keys and verification tokens together, ensure challenge echo uses raw body bytes before JSON parsing, and confirm the callback URL registered in the developer console matches the TLS SAN on your public hostname—including trailing slash discipline.
7. Why run this gateway on Mac mini class hardware?
macOS gives you launchd for reliable restarts, native Keychain integration for bot secrets, and a Unix toolchain that matches how most Apple-platform teams already debug TLS and proxy issues. Apple Silicon Mac mini systems combine low idle power—often on the order of a few watts at rest—with enough sustained CPU headroom for concurrent WebSocket fan-out and light Graph batching without the fan curve of a laptop under load.
Gatekeeper, System Integrity Protection, and FileVault layering also reduce unattended-gateway risk compared with ad-hoc Windows VMs on shared hypervisors, which matters when a single process holds Feishu, Lark, and Teams credentials at once.
If you want this OpenClaw footprint on stable metal without sourcing and racking your own mini, start with a dedicated remote Mac mini from ZoneMac so your allowlists, tokens, and observability baselines stay aligned with production from day one.
Need a stationary gateway Mac for Feishu, Lark, and Teams?
Rent a physical Mac mini node with predictable egress, wired-friendly profiles, and room for OpenClaw plus observability sidecars.