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

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

אתה צופה בתיעוד למפתחים

תיעוד זה מיועד למפתחים העובדים עם פלטפורמת המפתחים של Base44. למידע על connectors בעורך האפליקציות, ראה&#x20;
[שימוש ב-Connectors](https://docs.base44.com/he/Integrations/Connectors.md).

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()`](https://docs.base44.com/he/developers/references/sdk/docs/interfaces/connectors#getconnection) עבור OAuth connectors, או שימוש ב-[Stripe REST API](#stripe) ישירות עבור תשלומים

## הגדרה

כל connector הוא קובץ JSONC בתיקיית ה-connectors של הפרויקט שלך. הקובץ מגדיר את סוג האינטגרציה ואת ה-scopes שהאפליקציה שלך צריכה. כברירת מחדל התיקייה היא `base44/connectors/`, אבל אתה יכול להתאים את הנתיב ב[תצורת הפרויקט שלך](https://docs.base44.com/he/developers/backend/overview/project-structure.md#config-jsonc).

**connectors**

**googlecalendar.jsonc**

**slack.jsonc**

**slackbot.jsonc**

**notion.jsonc**

### דוגמה

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

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

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

**type** `string` *required*

מזהה סוג האינטגרציה. ראה את טבלת [שירותים נתמכים](https://docs.base44.com/he/developers/backend/resources/connectors.md#supported-services) עבור הרשימה המלאה של ערכים מקובלים.

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

**scopes** `array` *required*

מערך של OAuth scopes הנדרשים עבור האינטגרציה שלך. ה-scopes הספציפיים
תלויים בשירות החיצוני ובאילו פעולות האפליקציה שלך צריכה לבצע.
ראה את התיעוד של [connector permissions and
scopes](https://docs.base44.com/he/Integrations/connectors-catalog) עבור scopes
זמינים לכל שירות.

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

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

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

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

### הגדרת connector ללא פרויקט מקומי

`connectors push` קורא קבצי connector מהפרויקט שלך, אז הוא דורש checkout מקומי. כדי להגדיר connector ללא כזה, למשל באפליקציה שבנית בעורך האפליקציה או מסוכן AI, השתמש ב-[`connectors initiate`](https://docs.base44.com/he/developers/references/cli/commands/connectors-initiate). הוא מגדיר connector יחיד ישירות ב[אפליקציית יעד](https://docs.base44.com/he/developers/references/cli/commands/introduction.md#select-a-target-app) ומתחיל את זרימת ה-OAuth שלו, בלי לקרוא או לכתוב קבצים כלשהם. כדי להביא את התצורה של ה-connector לתוך פרויקט מקומי לאחר מכן, הרץ [`connectors pull`](https://docs.base44.com/he/developers/references/cli/commands/connectors-pull).

> [!NOTE]
>
> `connectors initiate` מגדיר connector יחיד ואף פעם לא מסיר אף אחד. `connectors push` מוסיף ומעדכן את ה-connectors שבקבצים המקומיים שלך, ועם `--force` הוא גם מסיר connectors שחסרים מהם.

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

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

> [tab] OAuth connectors
>
> קרא ל-[`connectors.getConnection()`](https://docs.base44.com/he/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] 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 });
> });
> ```

## Connector workflows

Connector workflows מאפשרים לפונקציות ה-backend שלך להגיב לאירועים מכלים מחוברים בזמן אמת. לדוגמה, אתה יכול להריץ פונקציה כאשר אימייל חדש מגיע ב-Gmail או קובץ משתנה ב-Google Drive. ראה טריגרים מסוג [Connector](https://docs.base44.com/he/Building-your-app/Creating-workflows.md#connector).

## ראה גם

* [Connectors overview](https://docs.base44.com/he/developers/backend/resources/connectors.md)
* [App user connectors](https://docs.base44.com/he/developers/backend/resources/connectors/app-user-connectors.md)
* [SDK connectors reference](https://docs.base44.com/he/developers/references/sdk/docs/interfaces/connectors.md#getconnection)
* [connectors push](https://docs.base44.com/he/developers/references/cli/commands/connectors-push.md)
* [connectors pull](https://docs.base44.com/he/developers/references/cli/commands/connectors-pull.md)
* [connectors initiate](https://docs.base44.com/he/developers/references/cli/commands/connectors-initiate.md)
* [deploy](https://docs.base44.com/he/developers/references/cli/commands/deploy.md)
* [Backend Functions](https://docs.base44.com/he/developers/backend/resources/backend-functions/overview.md)
* [Automations](https://docs.base44.com/he/developers/backend/resources/backend-functions/automations.md)

> [!NOTE]
>
> דף זה תורגם באמצעות בינה מלאכותית. למידע המדויק והעדכני ביותר, עיין ב[גרסה האנגלית](https://docs.base44.com/index.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.