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

# Module Connectors

> Gestion des tokens OAuth pour les services externes.

<Warning>
  Cette page fait partie d'une compétence d'agent de code IA et est écrite pour les agents, pas pour les humains. Pour la documentation Base44 lisible par un humain, consultez la [documentation développeur](/developers).
</Warning>

# Module Connectors

Gestion des tokens OAuth pour les services externes.

* **`base44.asServiceRole.connectors`** — tokens OAuth à l'échelle de l'application (backend/service role uniquement). Tous les utilisateurs partagent le même compte connecté.

## Sommaire

* [Service Role Connectors (`base44.asServiceRole.connectors`)](#service-role-connectors-base44asserviceroleconnectors)
* [Services disponibles](#available-services)
* [Définitions de types](#type-definitions)

***

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

Tokens OAuth à l'échelle de l'application. Le builder de l'application connecte le compte une fois ; tous les utilisateurs le partagent. **Backend/service role uniquement.**

### Méthodes

| Méthode                           | Signature                              | Description                                                    |
| --------------------------------- | -------------------------------------- | -------------------------------------------------------------- |
| `getConnection(integrationType)`  | `Promise<ConnectorConnectionResponse>` | Obtenir le token d'accès et la config de connexion facultative |
| `getAccessToken(integrationType)` | `Promise<string>`                      | ⚠️ **Déprécié** — utilisez `getConnection()` à la place        |

### Exemples

```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());
```

***

## Services disponibles

| Service               | Identifiant de type     |
| --------------------- | ----------------------- |
| 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`                 |

Exécutez `npx base44 connectors list-available` depuis le CLI pour voir tous les types disponibles.

***

## Prérequis de configuration

1. Forfait **Builder** ou supérieur
2. **Fonctions backend** activées (pour les connecteurs service role)
3. **Connecteur configuré** dans le tableau de bord Base44 (flux OAuth terminé)

## Notes importantes

* **Connecteurs service role** : un compte par connecteur et par application — tous les utilisateurs partagent le même compte connecté
* **Vous gérez les appels d'API** : Base44 fournit le token ; vous faites les requêtes API
* **Rafraîchissement du token** : Base44 gère le rafraîchissement du token automatiquement

***

## Définitions de types

```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>Cette page a été traduite à l'aide de l'IA. Pour les informations les plus précises et à jour, consultez la [version anglaise](/). </Note>
