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

> חבר חשבון שירות יחיד שכל משתמשי האפליקציה חולקים

<div className="dev-docs-banner">
  <div className="dev-docs-banner-content">
    <div className="dev-docs-banner-title">
      אתה צופה בתיעוד למפתחים
    </div>

    <div className="dev-docs-banner-text">
      תיעוד זה מיועד למפתחים העובדים עם פלטפורמת המפתחים של Base44. למידע על connectors בעורך האפליקציות, ראה{" "}
      <a href="/Integrations/Connectors">שימוש ב-Connectors</a>.
    </div>
  </div>
</div>

Shared connector מחבר חשבון אחד עבור כל האפליקציה. כל משתמשי האפליקציה חולקים את אותו OAuth token. השתמש בזה עבור service accounts, כמו פרסום לערוץ Slack של חברה, קריאה מ-Google Calendar משותף, או שאילתה של workspace משותף של Notion.

**להגדרת shared connector:**

1. [**הגדר**](#configure) קובץ JSONC עבור כל שירות שאתה צריך
2. [**פרוס ואשר**](#deploy-and-authorize) דרך ה-CLI
3. [**השתמש בפונקציות בקאנד**](#use-in-backend-functions) על ידי קריאה ל-[`getConnection()`](/developers/references/sdk/docs/interfaces/connectors#getconnection) עבור OAuth connectors, או שימוש ב-[Stripe REST API](#stripe) ישירות עבור תשלומים

## הגדרה

כל connector הוא קובץ JSONC בתיקיית ה-connectors של הפרויקט שלך. הקובץ מגדיר את סוג האינטגרציה ואת ה-scopes שהאפליקציה שלך צריכה. כברירת מחדל התיקייה היא `base44/connectors/`, אבל אתה יכול להתאים את הנתיב ב[תצורת הפרויקט שלך](/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>

### דוגמה

דוגמה זו מגדירה connector של Google Calendar עם scopes של קריאה וניהול אירועים:

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

### סימוכין שדות

<ResponseField name="type" type="string" required>
  מזהה סוג האינטגרציה. ראה את טבלת [שירותים נתמכים](/developers/backend/resources/connectors#supported-services) עבור הרשימה המלאה של ערכים מקובלים.

  כל סוג connector יכול להיות מוגדר רק פעם אחת בפרויקט שלך.
</ResponseField>

<ResponseField name="scopes" type="array" required>
  מערך של OAuth scopes הנדרשים עבור האינטגרציה שלך. ה-scopes הספציפיים
  תלויים בשירות החיצוני ובאילו פעולות האפליקציה שלך צריכה לבצע.
  ראה את התיעוד של [connector permissions and
  scopes](/Integrations/Connectors#connector-permissions) עבור scopes
  זמינים לכל שירות.
</ResponseField>

## פריסה ואישור

פרוס connectors עם [`connectors push`](/developers/references/cli/commands/connectors-push) או [`deploy`](/developers/references/cli/commands/deploy). כדי להוריד connectors קיימים מ-Base44, השתמש ב-[`connectors pull`](/developers/references/cli/commands/connectors-pull).

כאשר אתה דוחף, ה-CLI מטפל בכל connector בהתבסס על הסוג שלו:

* **OAuth connectors:** ה-CLI מבקש ממך לאשר כל connector אחד אחד. הוא מציע לפתוח את הדפדפן שלך אוטומטית, ואם תקבל, הוא עובר דרך דף האישור של כל אינטגרציה ברצף. לאחר שהאישור מסתיים, ה-OAuth tokens שלך נשמרים באופן מאובטח ואתה יכול לאחזר אותם באמצעות ה-SDK.
* **Stripe:** ה-CLI מקצה Stripe sandbox עבור האפליקציה שלך ומחזיר URL claim להשלמת onboarding. אין צורך בזרימת OAuth.

## שימוש בפונקציות בקאנד

לאחר הפריסה והאישור, השתמש ב-connector ב[פונקציות הבקאנד](/developers/backend/resources/backend-functions/overview) שלך. הגישה תלויה במודל ה-auth של ה-connector:

<Tabs>
  <Tab title="OAuth connectors">
    קרא ל-[`connectors.getConnection()`](/developers/references/sdk/docs/interfaces/connectors#getconnection) עם סוג ה-connector כדי לאחזר `accessToken` לביצוע קריאות API מאומתות. חלק מה-connectors גם מחזירים `connectionConfig` עם פרמטרים נוספים (לדוגמה subdomain או מזהה חשבון).

    דוגמה זו מאחזרת חיבור Google Calendar ושולפת אירועים קרובים:

    ```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 אינו משתמש ב-`getConnection()`. במקום זאת, הפלטפורמה שומרת את מפתחות ה-API של Stripe שלך כסודות אפליקציה כאשר אתה מקצה את ה-connector. בפונקציות הבקאנד שלך, קרא את `STRIPE_SECRET_KEY` מהסביבה וקרא ל-[Stripe REST API](https://docs.stripe.com/api) ישירות.

    דוגמה זו יוצרת session של Stripe Checkout ומחזירה את 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 מאפשרים לפונקציות הבקאנד שלך להגיב לאירועים משירותים מחוברים בזמן אמת. לדוגמה, אתה יכול להריץ פונקציה כאשר אימייל חדש מגיע ב-Gmail או קובץ משתנה ב-Google Drive.

הגדר connector automations בקובץ `function.jsonc` שלך לצד ה-automations האחרים שלך. ראה [Connector automations](/developers/backend/resources/backend-functions/automations#connector-automations) לסימוכין שדות מלא, אירועים נתמכים ותיעוד payload.

## ראה גם

* [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)

<Note>דף זה תורגם באמצעות בינה מלאכותית. למידע המדויק והעדכני ביותר, עיין ב[גרסה האנגלית](/). </Note>
