Skip to main content
Questa pagina fa parte di una skill per agenti di codifica IA ed è scritta per gli agenti, non per gli esseri umani. Per la documentazione Base44 leggibile dagli umani, consulta la documentazione per sviluppatori.

Modulo Connectors

Gestione dei token OAuth per servizi esterni.
  • base44.asServiceRole.connectors — Token OAuth con scope dell’app (solo backend/ruolo di servizio). Tutti gli utenti condividono lo stesso account connesso.

Contenuti


Connettori con ruolo di servizio (base44.asServiceRole.connectors)

Token OAuth con scope dell’app. Il costruttore dell’app connette l’account una volta; tutti gli utenti lo condividono. Solo backend/ruolo di servizio.

Metodi

MetodoFirmaDescrizione
getConnection(integrationType)Promise<ConnectorConnectionResponse>Ottieni il token di accesso e la configurazione di connessione opzionale
getAccessToken(integrationType)Promise<string>⚠️ Deprecato — usa getConnection() invece

Esempi

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

Servizi disponibili

ServizioIdentificatore di tipo
Airtableairtable
Boxbox
ClickUpclickup
Discorddiscord
Dropboxdropbox
GitHubgithub
Gmailgmail
Google Analyticsgoogle_analytics
Google BigQuerygooglebigquery
Google Calendargooglecalendar
Google Classroomgoogle_classroom
Google Docsgoogledocs
Google Drivegoogledrive
Google Search Consolegoogle_search_console
Google Sheetsgooglesheets
Google Slidesgoogleslides
HubSpothubspot
Linearlinear
LinkedInlinkedin
Microsoft Teamsmicrosoft_teams
Microsoft OneDriveone_drive
Notionnotion
Outlookoutlook
Salesforcesalesforce
SharePointshare_point
Slack Userslack
Slack Botslackbot
Splitwisesplitwise
TikToktiktok
Typeformtypeform
Wixwix
Wrikewrike
Esegui npx base44 connectors list-available dalla CLI per vedere tutti i tipi disponibili.

Requisiti di configurazione

  1. Piano Builder o superiore
  2. Funzioni backend abilitate (per i connettori con ruolo di servizio)
  3. Connettore configurato nella dashboard di Base44 (flusso OAuth completato)

Note importanti

  • Connettori con ruolo di servizio: un account per connettore per app — tutti gli utenti condividono lo stesso account connesso
  • Tu gestisci le chiamate API: Base44 fornisce il token; tu fai le effettive richieste API
  • Refresh del token: Base44 gestisce automaticamente il refresh del token

Definizioni di tipo

/**
 * 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>;
}

Questa pagina è stata tradotta utilizzando l’IA. Per informazioni più accurate e aggiornate, consulta la versione inglese.