Skip to main content
このページは AI コーディングエージェントスキルの一部で、人間ではなくエージェント向けに書かれています。人間向けの Base44 ドキュメントは デベロッパードキュメント を参照してください。

Connectors モジュール

外部サービスの OAuth トークン管理。
  • base44.asServiceRole.connectors — アプリスコープの OAuth トークン (バックエンド/サービスロールのみ)。すべてのユーザーが同じ接続済みアカウントを共有します。

目次


サービスロールコネクタ (base44.asServiceRole.connectors)

アプリスコープの OAuth トークン。アプリビルダーがアカウントを一度接続し、すべてのユーザーがそれを共有します。バックエンド/サービスロールのみ。

メソッド

メソッドシグネチャ説明
getConnection(integrationType)Promise<ConnectorConnectionResponse>アクセストークンとオプションの接続設定を取得
getAccessToken(integrationType)Promise<string>⚠️ 非推奨 — 代わりに getConnection() を使用

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

利用可能なサービス

サービスタイプ識別子
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
利用可能なすべてのタイプを見るには CLI から npx base44 connectors list-available を実行してください。

セットアップ要件

  1. Builder プラン 以上
  2. バックエンド関数 を有効化 (サービスロールコネクタ用)
  3. Base44 ダッシュボードで コネクタが構成済み (OAuth フロー完了)

重要な注意事項

  • サービスロールコネクタ: コネクタごと、アプリごとに 1 つのアカウント — すべてのユーザーが同じ接続済みアカウントを共有
  • API 呼び出しはあなたが処理: Base44 はトークンを提供します; あなたが実際の API リクエストを行います
  • トークンリフレッシュ: Base44 が自動的にトークンリフレッシュを処理します

型定義

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

このページは AI を使用して翻訳されました。最も正確で最新の情報については、英語版 を参照してください。