Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

feat(marketplace): let downloaders supply their own OAuth client in-app

Ruben Lütked45f00665c8a
diff --git a/jarvis/marketplace/connect_helpers.py b/jarvis/marketplace/connect_helpers.py
index c64673e6c8..e3943634cb 100644
--- a/jarvis/marketplace/connect_helpers.py
+++ b/jarvis/marketplace/connect_helpers.py
@@ -32,10 +32,22 @@ _PLACEHOLDER_MARKERS: tuple[str, ...] = (
"todo",
)
-# Plugins that share one Google OAuth client (per the catalog gmail hint:
-# "shares the Google client with Drive"). Their real client is resolved from the
-# shared `google_oauth_client_id` / `google_oauth_client_secret` secrets.
-_GOOGLE_FAMILY: frozenset[str] = frozenset({"gmail", "google_drive", "google_calendar"})
+# Bring-your-own OAuth client: map each PKCE plugin to the secret "family" whose
+# `<family>_oauth_client_id` / `<family>_oauth_client_secret` secrets override the
+# catalog client. This lets every downloader run their OWN production OAuth app
+# (the only way to stop a provider revoking refresh tokens — e.g. Google drops a
+# "Testing"-mode app's refresh token after 7 days) without editing the tracked
+# catalog or exporting env vars. gmail/drive/calendar share ONE Google client
+# (per the catalog hint "shares the Google client with Drive"); slack and asana
+# each get their own. DCR plugins (notion/linear/cloudflare) register their client
+# dynamically and are intentionally absent — they have no static client to supply.
+_OAUTH_CLIENT_FAMILY: dict[str, str] = {
+ "gmail": "google",
+ "google_drive": "google",
+ "google_calendar": "google",
+ "slack": "slack",
+ "asana": "asana",
+}
def is_placeholder_client_id(value: str | None) -> bool:
@@ -54,18 +66,24 @@ def resolve_pkce_client(
) -> tuple[str, str | None]:
"""Resolve the effective (client_id, client_secret) for a PKCE plugin.
- Precedence: a secret override wins over the catalog value, so the operator
- can supply a real Google OAuth client without editing the tracked catalog
- (which gets re-synced from the seed). For the Google family the shared
- `google_oauth_client_id` / `google_oauth_client_secret` secrets are used;
- other PKCE plugins (e.g. Slack) keep their real catalog client untouched.
+ Precedence: a `<family>_oauth_client_*` secret override wins over the catalog
+ value, so a downloader can supply their OWN production OAuth client without
+ editing the tracked catalog (which gets re-synced from the seed) or exporting
+ env vars. The Google family (gmail/drive/calendar) shares one `google_oauth_*`
+ pair; slack and asana each have their own. A plugin with no family mapping
+ keeps its real catalog client untouched. An unset/empty secret never displaces
+ the catalog value (``or`` fallback), so a placeholder catalog client still
+ builds a handler and the scheduler can honestly flag needs_reauth.
"""
- if plugin_id not in _GOOGLE_FAMILY:
+ family = _OAUTH_CLIENT_FAMILY.get(plugin_id)
+ if family is None:
return catalog_client_id, catalog_client_secret
from jarvis.core.config import get_secret
- cid = get_secret("google_oauth_client_id", "GOOGLE_OAUTH_CLIENT_ID")
- csec = get_secret("google_oauth_client_secret", "GOOGLE_OAUTH_CLIENT_SECRET")
+ cid = get_secret(f"{family}_oauth_client_id", f"{family.upper()}_OAUTH_CLIENT_ID")
+ csec = get_secret(
+ f"{family}_oauth_client_secret", f"{family.upper()}_OAUTH_CLIENT_SECRET"
+ )
return (cid or catalog_client_id, csec or catalog_client_secret)
diff --git a/jarvis/setup/wizard.py b/jarvis/setup/wizard.py
index cf8a31527d..64a4bba500 100644
--- a/jarvis/setup/wizard.py
+++ b/jarvis/setup/wizard.py
@@ -79,6 +79,11 @@ class SecretSpec:
help_url: str # Wo den Key holen
required_for: str # Menschen-lesbar: "Brain (Claude)" etc.
optional: bool = True
+ # When False, the slot is whitelisted for the API (so it CAN be stored from
+ # the app) but is NOT asked in the interactive first-run wizard. Used for
+ # advanced, app-only secrets (e.g. per-provider BYO OAuth client ids) so they
+ # don't lengthen onboarding.
+ prompt: bool = True
SECRETS: list[SecretSpec] = [
@@ -229,6 +234,69 @@ SECRETS: list[SecretSpec] = [
required_for="Telephony (call Jarvis on a Twilio phone number)",
optional=True,
),
+ # === Bring-your-own OAuth client (marketplace plugins) ===
+ # A downloader can run their OWN production OAuth app instead of the shipped
+ # catalog placeholder. This is the ONLY durable fix for provider-side
+ # refresh-token expiry: a Google OAuth app left in "Testing" status drops its
+ # refresh token after 7 days; publishing one's own app to production stops the
+ # clock. Resolved by `marketplace.connect_helpers.resolve_pkce_client` via the
+ # `<family>_oauth_client_*` keys. prompt=False: advanced + entered ONLY from
+ # the Plugins UI, never asked in the first-run wizard. The Google family
+ # (gmail/drive/calendar) shares ONE client pair.
+ SecretSpec(
+ key="google_oauth_client_id",
+ env_fallback="GOOGLE_OAUTH_CLIENT_ID",
+ label="Google OAuth Client ID (Gmail / Drive / Calendar)",
+ help_url="https://console.cloud.google.com/auth/clients",
+ required_for="Marketplace plugins (Google family) — your own OAuth client",
+ optional=True,
+ prompt=False,
+ ),
+ SecretSpec(
+ key="google_oauth_client_secret",
+ env_fallback="GOOGLE_OAUTH_CLIENT_SECRET",
+ label="Google OAuth Client Secret (Gmail / Drive / Calendar)",
+ help_url="https://console.cloud.google.com/auth/clients",
+ required_for="Marketplace plugins (Google family) — your own OAuth client",
+ optional=True,
+ prompt=False,
+ ),
+ SecretSpec(
+ key="slack_oauth_client_id",
+ env_fallback="SLACK_OAUTH_CLIENT_ID",
+ label="Slack OAuth Client ID",
+ help_url="https://api.slack.com/apps",
+ required_for="Marketplace plugin (Slack) — your own OAuth client",
+ optional=True,
+ prompt=False,
+ ),
+ SecretSpec(
+ key="slack_oauth_client_secret",
+ env_fallback="SLACK_OAUTH_CLIENT_SECRET",
+ label="Slack OAuth Client Secret",
+ help_url="https://api.slack.com/apps",
+ required_for="Marketplace plugin (Slack) — your own OAuth client",
+ optional=True,
+ prompt=False,
+ ),
+ SecretSpec(
+ key="asana_oauth_client_id",
+ env_fallback="ASANA_OAUTH_CLIENT_ID",
+ label="Asana OAuth Client ID",
+ help_url="https://app.asana.com/0/my-apps",
+ required_for="Marketplace plugin (Asana) — your own OAuth client",
+ optional=True,
+ prompt=False,
+ ),
+ SecretSpec(
+ key="asana_oauth_client_secret",
+ env_fallback="ASANA_OAUTH_CLIENT_SECRET",
+ label="Asana OAuth Client Secret",
+ help_url="https://app.asana.com/0/my-apps",
+ required_for="Marketplace plugin (Asana) — your own OAuth client",
+ optional=True,
+ prompt=False,
+ ),
]
@@ -285,6 +353,10 @@ def step_api_keys() -> dict[str, str]:
stored: dict[str, str] = {}
for spec in SECRETS:
+ if not spec.prompt:
+ # Advanced, app-only slot (e.g. a BYO OAuth client id) — whitelisted
+ # for the API but intentionally not asked here to keep onboarding short.
+ continue
existing = cfg.get_secret(spec.key)
marker = "✓ bereits hinterlegt" if existing else "–"
_println(f"• {spec.label} [{marker}]")
diff --git a/tests/unit/setup/test_oauth_client_secret_slots.py b/tests/unit/setup/test_oauth_client_secret_slots.py
new file mode 100644
index 0000000000..0acd109d47
--- /dev/null
+++ b/tests/unit/setup/test_oauth_client_secret_slots.py
@@ -0,0 +1,68 @@
+"""Bring-your-own OAuth client secret slots.
+
+The Google/Slack/Asana ``*_oauth_client_id`` / ``*_oauth_client_secret`` secrets
+let a downloader run their OWN production OAuth app (the only durable fix for
+provider-side refresh-token expiry — e.g. a Google "Testing" app drops its
+refresh token after 7 days). They must be:
+
+ * storable through the API (whitelisted via the wizard's ``SECRETS`` list), and
+ * NOT asked in the interactive setup wizard (advanced + optional; entered only
+ from the Plugins UI), so onboarding stays short.
+"""
+from __future__ import annotations
+
+from unittest.mock import patch
+
+from jarvis.setup.wizard import SECRETS, step_api_keys
+
+_OAUTH_CLIENT_KEYS = frozenset(
+ {
+ "google_oauth_client_id",
+ "google_oauth_client_secret",
+ "slack_oauth_client_id",
+ "slack_oauth_client_secret",
+ "asana_oauth_client_id",
+ "asana_oauth_client_secret",
+ }
+)
+
+
+def test_oauth_client_slots_declared() -> None:
+ keys = {s.key for s in SECRETS}
+ assert _OAUTH_CLIENT_KEYS <= keys
+
+
+def test_oauth_client_slots_are_optional_and_not_prompted() -> None:
+ by_key = {s.key: s for s in SECRETS}
+ for key in _OAUTH_CLIENT_KEYS:
+ spec = by_key[key]
+ assert spec.optional is True, f"{key} must be optional"
+ assert spec.prompt is False, f"{key} must not be prompted in the wizard"
+
+
+def test_oauth_client_keys_are_api_writable() -> None:
+ # ALLOWED_SECRET_KEYS is derived from SECRETS, so the POST /api/secrets/{key}
+ # route accepts the new keys (200) instead of rejecting them (404).
+ from jarvis.ui.web.provider_routes import ALLOWED_SECRET_KEYS
+
+ assert _OAUTH_CLIENT_KEYS <= ALLOWED_SECRET_KEYS
+
+
+def test_step_api_keys_skips_non_prompt_slots() -> None:
+ # The interactive wizard asks once per prompted secret and NEVER for a
+ # prompt=False slot — proving the 6 advanced OAuth-client slots don't bloat
+ # onboarding.
+ asked: list[str] = []
+
+ def _record(prompt: str, default: str | None = None) -> str:
+ asked.append(prompt)
+ return "" # user skips every prompt
+
+ with (
+ patch("jarvis.setup.wizard._ask", side_effect=_record),
+ patch("jarvis.setup.wizard.cfg.get_secret", return_value=None),
+ patch("jarvis.setup.wizard._println"),
+ ):
+ step_api_keys()
+
+ assert len(asked) == sum(1 for s in SECRETS if s.prompt)