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

# Módulo Connectors

> Gerenciamento de tokens OAuth para serviços externos.

<Warning>
  Esta página faz parte de uma habilidade de agente de código IA e é escrita para agentes, não para humanos. Para a documentação legível por humanos da Base44, veja a [documentação para desenvolvedores](/developers).
</Warning>

# Módulo Connectors

Gerenciamento de tokens OAuth para serviços externos.

* **`base44.asServiceRole.connectors`** — Tokens OAuth com escopo de aplicativo (apenas backend/service role). Todos os usuários compartilham a mesma conta conectada.

## Conteúdo

* [Conectores Service Role (`base44.asServiceRole.connectors`)](#service-role-connectors-base44asserviceroleconnectors)
* [Serviços disponíveis](#available-services)
* [Definições de tipo](#type-definitions)

***

## Conectores Service Role (`base44.asServiceRole.connectors`)

Tokens OAuth com escopo de aplicativo. O construtor do aplicativo conecta a conta uma vez; todos os usuários a compartilham. **Apenas backend/service role.**

### Métodos

| Método                            | Assinatura                             | Descrição                                                |
| --------------------------------- | -------------------------------------- | -------------------------------------------------------- |
| `getConnection(integrationType)`  | `Promise<ConnectorConnectionResponse>` | Obtém token de acesso e configuração de conexão opcional |
| `getAccessToken(integrationType)` | `Promise<string>`                      | ⚠️ **Obsoleto** — use `getConnection()` em vez disso     |

### Exemplos

```javascript theme={null}
// Backend function only
Deno.serve(async (req) => {
  const base44 = createClientFromRequest(req);

  // Recommended: use getConnection() for token + optional config
  const { accessToken, connectionConfig } = await base44.asServiceRole.connectors.getConnection("slack");

  const response = await fetch("https://slack.com/api/chat.postMessage", {
    method: "POST",
    headers: {
      "Authorization": `Bearer ${accessToken}`,
      "Content-Type": "application/json"
    },
    body: JSON.stringify({ channel: "#general", text: "Hello from Base44!" })
  });

  return Response.json(await response.json());
});
```

```javascript theme={null}
// Using connectionConfig (for services that need extra params, e.g. a subdomain)
const { accessToken, connectionConfig } = await base44.asServiceRole.connectors.getConnection("myservice");
const subdomain = connectionConfig?.subdomain;
const response = await fetch(`https://${subdomain}.example.com/api/v1/data`, {
  headers: { "Authorization": `Bearer ${accessToken}` }
});
```

```javascript theme={null}
// Google Calendar example
const { accessToken } = await base44.asServiceRole.connectors.getConnection("googlecalendar");

const events = await fetch(
  "https://www.googleapis.com/calendar/v3/calendars/primary/events?" +
  new URLSearchParams({ maxResults: "10", orderBy: "startTime", singleEvents: "true", timeMin: new Date().toISOString() }),
  { headers: { "Authorization": `Bearer ${accessToken}` } }
).then(r => r.json());
```

***

## Serviços disponíveis

| Serviço               | Identificador de tipo   |
| --------------------- | ----------------------- |
| Airtable              | `airtable`              |
| Box                   | `box`                   |
| ClickUp               | `clickup`               |
| Discord               | `discord`               |
| Dropbox               | `dropbox`               |
| GitHub                | `github`                |
| Gmail                 | `gmail`                 |
| Google Analytics      | `google_analytics`      |
| Google BigQuery       | `googlebigquery`        |
| Google Calendar       | `googlecalendar`        |
| Google Classroom      | `google_classroom`      |
| Google Docs           | `googledocs`            |
| Google Drive          | `googledrive`           |
| Google Search Console | `google_search_console` |
| Google Sheets         | `googlesheets`          |
| Google Slides         | `googleslides`          |
| HubSpot               | `hubspot`               |
| Linear                | `linear`                |
| LinkedIn              | `linkedin`              |
| Microsoft Teams       | `microsoft_teams`       |
| Microsoft OneDrive    | `one_drive`             |
| Notion                | `notion`                |
| Outlook               | `outlook`               |
| Salesforce            | `salesforce`            |
| SharePoint            | `share_point`           |
| Slack User            | `slack`                 |
| Slack Bot             | `slackbot`              |
| Splitwise             | `splitwise`             |
| TikTok                | `tiktok`                |
| Typeform              | `typeform`              |
| Wix                   | `wix`                   |
| Wrike                 | `wrike`                 |

Execute `npx base44 connectors list-available` na CLI para ver todos os tipos disponíveis.

***

## Requisitos de configuração

1. Plano **Builder** ou superior
2. **Funções de backend** ativadas (para conectores service role)
3. **Conector configurado** no painel da Base44 (fluxo OAuth concluído)

## Notas importantes

* **Conectores Service Role**: Uma conta por conector por aplicativo — todos os usuários compartilham a mesma conta conectada
* **Você lida com as chamadas de API**: A Base44 fornece o token; você faz as solicitações reais de API
* **Atualização de token**: A Base44 gerencia a atualização do token automaticamente

***

## Definições de tipo

```typescript theme={null}
/**
 * The type of external integration/connector (for service role connectors).
 * Examples: 'googlecalendar', 'slack', 'github', 'notion', etc.
 */
type ConnectorIntegrationType = string;

/** Connection details returned by getConnection(). */
interface ConnectorConnectionResponse {
  /** The OAuth access token for the external service. */
  accessToken: string;
  /** Key-value configuration for the connection, or null if not needed. */
  connectionConfig: Record<string, string> | null;
}

/** Service role connectors module (app-scoped OAuth). Backend only. */
interface ConnectorsModule {
  /**
   * Retrieves the OAuth access token and optional connection config.
   * @param integrationType - e.g., 'googlecalendar', 'slack', 'github'.
   */
  getConnection(integrationType: ConnectorIntegrationType): Promise<ConnectorConnectionResponse>;

  /**
   * @deprecated Use getConnection() instead.
   * Retrieves only the OAuth access token string.
   */
  getAccessToken(integrationType: ConnectorIntegrationType): Promise<string>;
}

```

<Note>Esta página foi traduzida usando IA. Para informações mais precisas e atualizadas, consulte a [versão em inglês](/). </Note>
