> ## 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.

# Shared connectors

> Connect a single service account that all app users share

<div className="dev-docs-banner">
  <div className="dev-docs-banner-content">
    <div className="dev-docs-banner-title">
      You're viewing developer documentation
    </div>

    <div className="dev-docs-banner-text">
      This documentation is for developers working with the Base44 developer
      platform. For information about connectors in the app editor, see{" "}
      <a href="/Integrations/Connectors">Using Connectors</a>.
    </div>
  </div>
</div>

A shared connector connects one account for the whole app. All app users share the same OAuth token. Use this for service accounts, like posting to a company Slack channel, reading from a shared Google Calendar, or querying a shared Notion workspace.

**To set up a shared connector:**

1. [**Configure**](#configure) a JSONC file for each service you need
2. [**Deploy and authorize**](#deploy-and-authorize) via the CLI
3. [**Use in backend functions**](#use-in-backend-functions) by calling [`getConnection()`](/developers/references/sdk/docs/interfaces/connectors#getconnection) for OAuth connectors, or using the [Stripe REST API](#stripe) directly for payments

## Configure

Each connector is a JSONC file in your project's connectors directory. The file defines the integration type and the scopes your app needs. By default the directory is `base44/connectors/`, but you can customize the path in your [project configuration](/developers/backend/overview/project-structure#config-jsonc).

<Tree>
  <Tree.Folder name="connectors" defaultOpen>
    <Tree.File name="googlecalendar.jsonc" />

    <Tree.File name="slack.jsonc" />

    <Tree.File name="slackbot.jsonc" />

    <Tree.File name="notion.jsonc" />
  </Tree.Folder>
</Tree>

### Example

This example configures a Google Calendar connector with read and event management scopes:

```jsonc theme={null}
{
  "type": "googlecalendar",
  "scopes": [
    "https://www.googleapis.com/auth/calendar.readonly",
    "https://www.googleapis.com/auth/calendar.events",
  ],
}
```

### Field reference

<ResponseField name="type" type="string" required>
  The integration type identifier. See the [supported services](/developers/backend/resources/connectors#supported-services) table for the full list of accepted values.

  Each connector type can only be defined once in your project.
</ResponseField>

<ResponseField name="scopes" type="array" required>
  Array of OAuth scopes required for your integration. The specific scopes
  depend on the external service and what operations your app needs to perform.
  See the [connector permissions and
  scopes](/Integrations/Connectors#connector-permissions) documentation for
  available scopes for each service.
</ResponseField>

## Deploy and authorize

Deploy connectors with [`connectors push`](/developers/references/cli/commands/connectors-push) or [`deploy`](/developers/references/cli/commands/deploy). To download existing connectors from Base44, use [`connectors pull`](/developers/references/cli/commands/connectors-pull).

When you push, the CLI handles each connector based on its type:

* **OAuth connectors:** The CLI prompts you to authorize each connector one by one. It suggests opening your browser automatically, and if you accept, it iterates through each integration's authorization page sequentially. After authorization completes, your OAuth tokens are stored securely and you can retrieve them using the SDK.
* **Stripe:** The CLI provisions a Stripe sandbox for your app and returns a claim URL to complete onboarding. No OAuth flow is needed.

## Use in backend functions

Once deployed and authorized, use the connector in your [backend functions](/developers/backend/resources/backend-functions/overview). The approach depends on the connector's auth model:

<Tabs>
  <Tab title="OAuth connectors">
    Call [`connectors.getConnection()`](/developers/references/sdk/docs/interfaces/connectors#getconnection) with the connector type to retrieve an `accessToken` for making authenticated API calls. Some connectors also return a `connectionConfig` with additional parameters (e.g. a subdomain or account ID).

    This example retrieves a Google Calendar connection and fetches upcoming events:

    ```typescript theme={null}
    const { accessToken } =
      await base44.asServiceRole.connectors.getConnection("googlecalendar");

    const timeMin = new Date().toISOString();
    const url = `https://www.googleapis.com/calendar/v3/calendars/primary/events?maxResults=10&orderBy=startTime&singleEvents=true&timeMin=${timeMin}`;

    const response = await fetch(url, {
      headers: { Authorization: `Bearer ${accessToken}` },
    });

    const events = await response.json();
    ```
  </Tab>

  <Tab title="Stripe">
    Stripe does not use `getConnection()`. Instead, the platform stores your Stripe API keys as app secrets when you provision the connector. In your backend functions, read `STRIPE_SECRET_KEY` from the environment and call the [Stripe REST API](https://docs.stripe.com/api) directly.

    This example creates a Stripe Checkout session and returns the payment URL:

    ```typescript theme={null}
    const STRIPE_SECRET_KEY = Deno.env.get("STRIPE_SECRET_KEY");

    Deno.serve(async (req) => {
      const { priceId, successUrl, cancelUrl } = await req.json();

      const response = await fetch("https://api.stripe.com/v1/checkout/sessions", {
        method: "POST",
        headers: {
          Authorization: `Bearer ${STRIPE_SECRET_KEY}`,
          "Content-Type": "application/x-www-form-urlencoded",
        },
        body: new URLSearchParams({
          "payment_method_types[]": "card",
          "line_items[0][price]": priceId,
          "line_items[0][quantity]": "1",
          mode: "payment",
          success_url: successUrl || `${req.headers.get("origin")}?success=true`,
          cancel_url: cancelUrl || `${req.headers.get("origin")}?canceled=true`,
        }),
      });

      const session = await response.json();
      return Response.json({ url: session.url });
    });
    ```
  </Tab>
</Tabs>

## Connector automations

Connector automations let your backend functions respond to events from connected services in real time. For example, you can run a function when a new email arrives in Gmail or a file changes in Google Drive.

Configure connector automations in your `function.jsonc` file alongside your other automations. See [Connector automations](/developers/backend/resources/backend-functions/automations#connector-automations) for the full field reference, supported events, and payload documentation.

## See also

* [Connectors overview](/developers/backend/resources/connectors)
* [App user connectors](/developers/backend/resources/connectors/app-user-connectors)
* [SDK connectors reference](/developers/references/sdk/docs/interfaces/connectors#getconnection)
* [connectors push](/developers/references/cli/commands/connectors-push)
* [connectors pull](/developers/references/cli/commands/connectors-pull)
* [deploy](/developers/references/cli/commands/deploy)
* [Backend Functions](/developers/backend/resources/backend-functions/overview)
* [Automations](/developers/backend/resources/backend-functions/automations)
