> ## Documentation Index
> Fetch the complete documentation index at: https://docs.base44.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Base44 connectors: App connectors (mobile apps)

> source commit is in /SOURCE_COMMIT at the repository root. Edits here are overwritten by

> [!WARNING]
>
> This page is part of an AI coding agent skill and is written for agents, not humans. For the human-readable Base44 docs, see the [developer documentation](https://docs.base44.com/developers).

# Base44 connectors: App connectors (mobile apps)

\<app\_connectors>
App connectors allow you to integrate with external services in an easy way using OAuth.
App connectors come in the following types:

\<connector\_types>

1. **Shared connector**: The app builder connects their own account. All app users share the app builder's single connection. Backend functions call the external API on the app builder's behalf. See \<connector\_workflow\_rules>.
2. **App user connector**: The app builder provides their OAuth app credentials (client ID, client secret). Each App User connects their own account individually. Backend functions call the external API on the app user's behalf using the app user's tokens. See \<app\_user\_connectors>.
3. **BYO shared connector**: A workspace admin registers their own OAuth app (a workspace connector). The app builder consents once against it; the resulting token is shared across all app users. Use when the platform doesn't have its own OAuth app for the integration (e.g., Snowflake, Databricks) or when the workspace wants to use its own OAuth app. See \<byo\_shared\_connectors>.
   \</connector\_types>

Backend functions MUST be enabled for each connector type.

\<connector\_decision\_flow>
Connecting a connector happens outside the code: `base44 connectors list-available` lists the catalog, and the Base44 MCP `list_connectors` tool is the one source of each connector's details for this app (description, scopes, auth status, `connector_mode`); connect or re-scope a shared connector with `initiate_connector_connection` / `base44 connectors initiate` passing the complete scope set (it replaces, never merges), and let the user finish OAuth in their browser. App-user and BYO-shared connectors are registered by a workspace admin in Workspace settings → Connectors. Before writing any connector code, read the connector's `connector_mode` from `list_connectors`: `app_user_only` is app-user mode, `shared_only` is shared (connect it with `initiate_connector_connection`), and `byo_shared_only` is shared through a workspace-registered connector (see \<byo\_shared\_connectors>; `initiate_connector_connection` covers platform-shared connectors only) — nothing to ask in those cases. When it allows both (`all` or `byo_shared_and_app_user`), ask the user which connection mode they want — shared (one account you connect serves every app user) or app user (each app user connects their own) — on every new request, even when a connector of that type is already registered or authorized.
\</connector\_decision\_flow>

\<supported\_connectors>
The catalog is live: list it with `list_connectors` (MCP) or `base44 connectors list-available`; each entry gives the display name and its `integration_type`.
\</supported\_connectors>

Use the connector's integration\_type for getConnection.
Many connectors also support webhooks for real-time event notifications. Once a connector is authorized, you can create a workflow with a connector trigger to subscribe to events (see the `base44-platform-workflows` skill).

\<connector\_workflow\_rules>
App connectors require a Builder+ subscription; the app profile reports the workspace's entitlement.

When the user asks to connect or use an external service:

1. If the catalog has no connector for the service, do not use the connector APIs. Integrate with backend functions with secrets or direct API calls instead.
2. Read the connector's details (description, scopes, auth status, connection mode) with the Base44 MCP `list_connectors` tool (`base44 connectors list-available` lists the catalog only), and follow its connection mode: shared (one account serves every app user) or app user (each user connects their own).
3. Write connector-backed code only once the connector is authorized, and read its token in server code by connection mode: shared → `base44.asServiceRole.connectors.getConnection(integration_type)`; BYO shared → `base44.asServiceRole.connectors.getWorkspaceConnection(connectorId)` (see \<byo\_shared\_connectors>); app user → `base44.asServiceRole.connectors.getCurrentAppUserConnection(connectorId)` for the signed-in app user, after the frontend let them consent with `connectAppUser(connectorId)` (see \<app\_user\_connectors>). Never serve one app user's data through the shared account's token. Then make the API calls yourself.
   \</connector\_workflow\_rules>
   \</app\_connectors>

\<byo\_shared\_connectors>
A workspace-registered OAuth app (a workspace connector) that the app builder consents once against. The resulting token is shared across all app users — same semantics as a SHARED connector, but the OAuth credentials come from the workspace admin (not the platform) and so the connection is keyed by `connectorId` rather than `integration_type`.

**Prerequisite — the workspace connector must already exist.** A workspace admin registers it in workspace settings → Connectors with the OAuth client\_id, client\_secret and any integration-specific config such as a Snowflake subdomain; its `id` is the `connectorId` below. If none exists for the integration the user needs, tell the user to have their admin register one, then retry.

Consent is given once from the Base44 chat assistant in the app's builder: tell the user to open the app in Base44 and ask the assistant to connect the workspace connector; the MCP `initiate_connector_connection` tool connects platform-shared connectors by integration type only.

**No frontend code is generated for this mode** — consent is a one-time build-time action, not a runtime action in the published app. Unlike APP\_USER, there is no `connectAppUser` call.

**Backend function — use `getWorkspaceConnection(connectorId)`:**

```
import { createClientFromRequest } from 'npm:@base44/sdk@0.8.54';

export default async function(req) {
  try {
    const base44 = createClientFromRequest(req);

    // connectorId is the workspace connector's id, e.g. "abc123"
    const { accessToken, connectionConfig } = await base44.asServiceRole.connectors.getWorkspaceConnection("abc123");

    // connectionConfig carries any admin-configured parameters such as
    // subdomain, workspace URL, etc. `connection_config_fields` from `list_connectors`
    // names the admin-entered ones; providers may add an API host or instance URL.
    const apiUrl = `https://${connectionConfig.subdomain}.snowflakecomputing.com/api/v2/statements`;

    const response = await fetch(apiUrl, {
      method: "POST",
      headers: {
        "Authorization": `Bearer ${accessToken}`,
        "Content-Type": "application/json",
      },
      body: JSON.stringify({ statement: "SELECT COUNT(*) FROM my_table" }),
    });
    const data = await response.json();
    return Response.json(data);
  } catch (error) {
    return Response.json({ error: error.message }, { status: 500 });
  }
}
```

Differences from SHARED code-gen:

* A dedicated `getWorkspaceConnection(connectorId)` method is called with the connector's `id` as a string — NOT `getConnection`, which is reserved for platform-shared connectors keyed by `"<integration_type>"`.
* `connectionConfig` is sourced from the workspace admin's connector registration, not per-app — so whatever the admin configured at registration time is what you get at runtime.
  \</byo\_shared\_connectors>

\<app\_user\_connectors>
App-user connectors are registered per workspace (workspace settings → Connectors); each has an `id`, the `connectorId` below. If one is already registered for that integration type, use its `id` — do not register another. Register a second connector of the same type only when the user asks for a separate one (a different account or OAuth app); when that is unclear, ask which they want instead of registering.

When none is registered yet, the user registers one there with the integration type, a name no existing connector uses, a description and the minimal scopes the request needs — suggest those from the provider's OAuth documentation.

When implementing app-user connector functionality:

1. **Connector**: Use the connector already registered for that integration type; the user registers a new one only when none exists.
2. **Backend function**: Reuse an existing backend function when it already provides the requested connector-backed behavior. If no suitable function exists, create or edit one that uses `base44.asServiceRole.connectors.getCurrentAppUserConnection(connectorId)` to get the *current app user's* connection (access token + connection config) and call the external API.
3. **Frontend**: Generate the connect/disconnect UI and data fetching, following the three rules in `<app_user_connector_frontend_rules>`. Use the connector's `id` as the `connectorId`.
4. **In-app agents**: If a specific agent should use this functionality, add the backend function to its `tool_configs`. Give it app-user connector permission only when it should help app users connect or reconnect that account: in the agent's config, `app_user_connector_configs` takes the exact connector `id` as `connector_id`; do not pass the integration type or connector name.

\<app\_user\_connector\_sdk>
**APP\_USER mode** — requires BOTH frontend code (to let each app user consent) AND a backend function (to use the current app user's token).

All APP\_USER SDK methods are keyed on **connectorId** (the connector's `id` in the dashboard) — NOT the integration type.

**SDK methods:**

| Connector mode | Frontend | Backend function |
| - | - | - |
| SHARED | None (no frontend SDK) | `base44.asServiceRole.connectors.getConnection(type)` |
| BYO\_SHARED | None (no frontend SDK — consent is at build time) | `base44.asServiceRole.connectors.getWorkspaceConnection(connectorId)` |
| APP\_USER | `base44.connectors.connectAppUser(connectorId)`, `base44.connectors.disconnectAppUser(connectorId)` | `base44.asServiceRole.connectors.getCurrentAppUserConnection(connectorId)` |

* `connectAppUser(connectorId)` — returns a URL string. Open it so the app user can complete OAuth consent.
* `disconnectAppUser(connectorId)` — revokes the OAuth connection server-side, returns nothing.
* `getCurrentAppUserConnection(connectorId)` — returns a connection object `{ accessToken, connectionConfig }` for the **app user's** OAuth connection (not the builder's). Destructure `accessToken` and optionally `connectionConfig` (e.g. `const { accessToken, connectionConfig } = await ...getCurrentAppUserConnection(connectorId)`). `connectionConfig` may contain connector-specific parameters (e.g. subdomain, workspace URL) — it holds the admin-entered fields (`connection_config_fields` from `list_connectors` names them) plus any the provider returned at connection time, such as an API host or instance URL — when the provider's API is per-account, take the host from it instead of hardcoding the default.

**Backend function example:**

```
import { createClientFromRequest } from 'npm:@base44/sdk@0.8.54';

export default async function(req) {
  try {
    const base44 = createClientFromRequest(req);
    const user = await base44.auth.me();
    if (!user) {
      return Response.json({ error: 'Unauthorized' }, { status: 401 });
    }

    // connectorId is the registered connector's id, e.g. "abc123"
    const { accessToken, connectionConfig } = await base44.asServiceRole.connectors.getCurrentAppUserConnection(connectorId);

    const response = await fetch('https://www.googleapis.com/calendar/v3/calendars/primary/events', {
      headers: { 'Authorization': `Bearer ${accessToken}` }
    });
    const data = await response.json();
    return Response.json({ events: data.items || [] });
  } catch (error) {
    return Response.json({ error: error.message }, { status: 500 });
  }
}
```

\</app\_user\_connector\_sdk>

\<app\_user\_connector\_frontend\_rules>
**Three rules you MUST follow when generating frontend code that uses app user connectors. Design the page UI however fits the app — but always apply these rules:**

**Rule 1 — Auth gate:** `connectAppUser()` will fail if the app user is not signed in. Use `base44.auth.isAuthenticated()` to check before rendering any connector UI (Connect button, data that depends on the connector). If not authenticated, show a login button that calls `base44.auth.redirectToLogin()`.

**Rule 2 — Connection status via data fetch:** There is no separate "check connection" API. Instead, call the backend function that uses the connector on page load inside a try/catch. If it succeeds → user is connected (and you already have the data). If it throws → user is not connected, show the Connect button. Extract this fetch as a reusable function — you will call it again in Rule 3.

**Rule 3 — Auto-refresh after OAuth:** The OAuth flow opens in the device browser. When the user finishes and comes back, the screen doesn't know. To fix this: open the URL with `Linking.openURL` (expo-linking) and subscribe to `AppState` (react-native) — when it becomes `active`, call the reusable fetch from Rule 2 to refresh data automatically.

**How the three rules connect (hooks/handlers skeleton):**

```
const [user, setUser] = useState(null);
const [data, setData] = useState(null);
const [connected, setConnected] = useState(false);
const [loading, setLoading] = useState(true);

// Rule 2: reusable fetch — doubles as connection check AND data loader
const fetchData = async () => {
  try {
    const res = await base44.functions.invoke("myBackendFunction", {});
    setData(res.data);
    setConnected(true);
  } catch {
    setConnected(false);
  }
};

// Rule 1+2: check auth first, then fetch to detect connection status
useEffect(() => {
  base44.auth.isAuthenticated().then(async (authed) => {
    if (authed) {
      const me = await base44.auth.me();
      setUser(me);
      await fetchData();
    }
    setLoading(false);
  });
}, []);

// Rule 3: open the OAuth URL, re-fetch when the app returns to the foreground
// import * as Linking from "expo-linking"; import { AppState } from "react-native";
const handleConnect = async () => {
  const url = await base44.connectors.connectAppUser(CONNECTOR_ID);
  await Linking.openURL(url);
  const sub = AppState.addEventListener("change", (state) => {
    if (state === "active") {
      sub.remove();
      fetchData();
    }
  });
};

const handleDisconnect = async () => {
  await base44.connectors.disconnectAppUser(CONNECTOR_ID);
  setConnected(false);
  setData(null);
};

// Then in your JSX, use loading, user, and connected to decide what to render.
// If !user, show a login button that calls base44.auth.redirectToLogin().
// Design the UI however fits the app.
```

\</app\_user\_connector\_frontend\_rules>
\</app\_user\_connectors>


## Related topics

- [App user connectors](https://docs.base44.com/developers/backend/resources/connectors/app-user-connectors.md)
- [Using connectors](https://docs.base44.com/Integrations/Connectors.md)
- [Google Workspace connectors](https://docs.base44.com/Integrations/google-workspace-connectors.md)
- [Connecting Snowflake to your app](https://docs.base44.com/Integrations/snowflake-connector.md)
- [Connecting Databricks to your app](https://docs.base44.com/Integrations/databricks-connector.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.