Google Workspace 外掛程式的資訊清單

外掛程式會使用資訊清單檔案檔案 設定應用程式及其作業的特定詳細資料。

本文件詳細說明如何設定 Google Workspace 外掛程式。

Google Workspace 外掛程式的資訊清單結構

Google Workspace 外掛程式使用資訊清單檔案來定義 外掛程式 外觀和行為

Google Workspace 外掛程式的資訊清單屬性如下: 這些分類是在資訊清單物件結構的 addOns 區段中。

Google Workspace 外掛程式資訊清單設定範例

以下資訊清單範例呈現了資訊清單檔案中所定義的部分 Google Workspace 外掛程式,包括下列層面:

  • addOns.common 清單的這個部分定義了名稱、標誌網址、顏色和其他 與主機無關的一般設定。
  • 資訊清單定義了一般首頁,但也會定義 日曆、雲端硬碟、文件、 試算表和簡報專屬首頁。 Gmail 會使用預設首頁。
  • 範例資訊清單設定啟用下列功能:
    • 日曆 eventOpeneventUpdated 觸發條件。
    • (僅限 Apps Script) 兩個日曆
    • 兩項通用動作。
    • 開車 onItemsSelectedTrigger
    • Gmail 撰寫動作和內容相關觸發條件。
    • 文件 linkPreviewTriggers 物件。如要瞭解這個觸發條件 請參閱「使用智慧型方塊預覽連結」。
    • 文件 createActionTriggers 物件。如要瞭解這個觸發條件 請參閱「使用 @ 選單建立第三方資源」。
    • 文件、試算表、文件專屬的介面 和簡報
  • oauthScopes 欄位 設定專案的授權範圍 (通常必須 外掛程式)。
  • (僅限 Apps Script) urlFetchWhitelist 欄位是一種欄位,能確保任何擷取的端點都與指定的端點相符 HTTPS 網址前置字元清單若需更多資訊,請參閲 將網址加入許可清單

示例中的連結會導向說明 相應欄位中的值 Apps Script 資訊清單參考文件 和 HTTP Google Workspace 外掛程式。

Apps Script

{
  "addOns": {
    "calendar": {
      "createSettingsUrlFunction": "getConferenceSettingsPageUrl",
      "conferenceSolution": [{
        "id": "my-video-conf",
        "logoUrl": "https://lh3.googleusercontent.com/...",
        "name": "My Video Conference",
        "onCreateFunction": "onCreateMyVideoConference"
      }, {
        "id": "my-streamed-conf",
        "logoUrl": "https://lh3.googleusercontent.com/...",
        "name": "My Streamed Conference",
        "onCreateFunction": "onCreateMyStreamedConference"
      }],
      "currentEventAccess": "READ_WRITE",
      "eventOpenTrigger": {
        "runFunction": "onCalendarEventOpen"
      },
      "eventUpdateTrigger": {
        "runFunction": "onCalendarEventUpdate"
      },
      "eventAttachmentTrigger": {
        "label": "My Event Attachment",
        "runFunction": "onCalendarEventAddAttachment"
      },
      "homepageTrigger": {
        "runFunction": "onCalendarHomePageOpen",
        "enabled": true
      }
    },
    "common": {
      "homepageTrigger": {
        "runFunction": "onDefaultHomePageOpen",
        "enabled": true
      },
      "layoutProperties": {
        "primaryColor": "#ff392b",
        "secondaryColor": "#d68617"
      },
      "logoUrl": "https://ssl.gstatic.com/docs/script/images/logo/script-64.png",
      "name": "Demo Google Workspace Add-on",
      "openLinkUrlPrefixes": [
        "https://mail.google.com/",
        "https://script.google.com/a/google.com/d/",
        "https://drive.google.com/a/google.com/file/d/",
        "https://www.example.com/"
      ],
      "universalActions": [{
        "label": "Open settings",
        "runFunction": "getSettingsCard"
      }, {
        "label": "Open Help URL",
        "openLink": "https://www.example.com/help"
      }],
      "useLocaleFromApp": true
    },
    "drive": {
      "homepageTrigger": {
        "runFunction": "onDriveHomePageOpen",
        "enabled": true
      },
      "onItemsSelectedTrigger": {
        "runFunction": "onDriveItemsSelected"
      }
    },
    "gmail": {
      "composeTrigger": {
        "selectActions": [
          {
            "text": "Add images to email",
            "runFunction": "getInsertImageComposeCards"
          }
        ],
        "draftAccess": "METADATA"
      },
      "contextualTriggers": [
        {
          "unconditional": {},
          "onTriggerFunction": "onGmailMessageOpen"
        }
      ]
    },
    "docs": {
      "homepageTrigger": {
        "runFunction": "onEditorsHomepage"
      },
      "onFileScopeGrantedTrigger": {
        "runFunction": "onFileScopeGrantedEditors"
      },
      "linkPreviewTriggers": [
        {
        "runFunction": "onLinkPreview",
        "patterns": [
            {
              "hostPattern": "example.com",
              "pathPrefix": "example-path"
            }
        ],
        "labelText": "Link preview",
        "localizedLabelText": {
          "es": "Link preview localized in Spanish"
        },
        "logoUrl": "https://www.example.com/images/smart-chip-icon.png"
        }
      ],
      "createActionTriggers": [
        {
          "id": "exampleId",
          "labelText": "Example label text",
          "localizedLabelText": {
            "es": "Label text localized in Spanish"
          },
          "runFunction": "exampleFunction",
          "logoUrl": "https://www.example.com/images/case.png"
        }
      ]
    },
    "sheets": {
      "homepageTrigger": {
        "runFunction": "onEditorsHomepage"
      },
      "onFileScopeGrantedTrigger": {
        "runFunction": "onFileScopeGrantedEditors"
      }
    },
    "slides": {
      "homepageTrigger": {
        "runFunction": "onEditorsHomepage"
      },
      "onFileScopeGrantedTrigger": {
        "runFunction": "onFileScopeGrantedEditors"
      }
    }
  },
  "oauthScopes": [
    "https://www.googleapis.com/auth/calendar.addons.execute",
    "https://www.googleapis.com/auth/calendar.addons.current.event.read",
    "https://www.googleapis.com/auth/calendar.addons.current.event.write",
    "https://www.googleapis.com/auth/drive.addons.metadata.readonly",
    "https://www.googleapis.com/auth/gmail.addons.current.action.compose",
    "https://www.googleapis.com/auth/gmail.addons.current.message.metadata",
    "https://www.googleapis.com/auth/userinfo.email",
    "https://www.googleapis.com/auth/script.external_request",
    "https://www.googleapis.com/auth/script.locale",
    "https://www.googleapis.com/auth/script.scriptapp",
    "https://www.googleapis.com/auth/drive.file",
    "https://www.googleapis.com/auth/documents.currentonly",
    "https://www.googleapis.com/auth/spreadsheets.currentonly",
    "https://www.googleapis.com/auth/presentations.currentonly",
    "https://www.googleapis.com/auth/workspace.linkpreview"
  ],
  "urlFetchWhitelist": [
    "https://www.example.com/myendpoint/"
  ]
}

HTTP

{
  "addOns": {
    "calendar": {
      "currentEventAccess": "READ_WRITE",
      "eventOpenTrigger": {
        "runFunction": "https://myownpersonaldomain.com/mypage?trigger=onCalendarEventOpen"
      },
      "eventUpdateTrigger": {
        "runFunction": "https://myownpersonaldomain.com/mypage?trigger=onCalendarEventUpdate"
      },
      "eventAttachmentTrigger": {
        "label": "My Event Attachment",
        "runFunction": "https://myownpersonaldomain.com/mypage?trigger=onCalendarEventAddAttachment"
      },
      "homepageTrigger": {
        "runFunction": "https://myownpersonaldomain.com/mypage?trigger=onCalendarHomePageOpen",
        "enabled": true
      }
    },
    "common": {
      "homepageTrigger": {
        "runFunction": "https://myownpersonaldomain.com/mypage?trigger=onDefaultHomePageOpen",
        "enabled": true
      },
      "layoutProperties": {
        "primaryColor": "#ff392b",
        "secondaryColor": "#d68617"
      },
      "logoUrl": "https://ssl.gstatic.com/docs/script/images/logo/script-64.png",
      "name": "Demo Google Workspace Add-on",
      "openLinkUrlPrefixes": [
        "https://mail.google.com/",
        "https://script.google.com/a/google.com/d/",
        "https://drive.google.com/a/google.com/file/d/",
        "https://www.example.com/"
      ],
      "universalActions": [{
        "label": "Open settings",
        "runFunction": "https://myownpersonaldomain.com/mypage?trigger=getSettingsCard"
      }, {
        "label": "Open Help URL",
        "openLink": "https://www.example.com/help"
      }],
      "useLocaleFromApp": true
    },
    "drive": {
      "homepageTrigger": {
        "runFunction": "https://myownpersonaldomain.com/mypage?trigger=onDriveHomePageOpen",
        "enabled": true
      },
      "onItemsSelectedTrigger": {
        "runFunction": "https://myownpersonaldomain.com/mypage?trigger=onDriveItemsSelected"
      }
    },
    "gmail": {
      "composeTrigger": {
        "actions": [
          {
            "label": "Add images to email",
            "runFunction": "https://myownpersonaldomain.com/mypage?trigger=getInsertImageComposeCards"
          }
        ],
        "draftAccess": "METADATA"
      },
      "contextualTriggers": [
        {
          "unconditional": {},
          "onTriggerFunction": "https://myownpersonaldomain.com/mypage?trigger=onGmailMessageOpen"
        }
      ]
    },
    "docs": {
      "homepageTrigger": {
        "runFunction": "https://myownpersonaldomain.com/mypage?trigger=onEditorsHomepage"
      },
      "onFileScopeGrantedTrigger": {
        "runFunction": "https://myownpersonaldomain.com/mypage?trigger=onFileScopeGrantedEditors"
      },
      "linkPreviewTriggers": [
        {
          "runFunction": "https://myownpersonaldomain.com/mypage?trigger=onLinkPreview",
          "patterns": [
              {
                "hostPattern": "example.com",
                "pathPrefix": "example-path"
              }
          ],
          "labelText": "Link preview",
          "localizedLabelText": {
            "es": "Link preview localized in Spanish"
          },
          "logoUrl": "https://www.example.com/images/smart-chip-icon.png"
        }
      ],
      "createActionTriggers": [
        {
          "id": "exampleId",
          "labelText": "Example label text",
          "localizedLabelText": {
            "es": "Label text localized in Spanish"
          },
          "runFunction": "https://myownpersonaldomain.com/mypage?trigger=onCreateAction",
          "logoUrl": "https://www.example.com/images/case.png"
        }
      ]
    },
    "sheets": {
      "homepageTrigger": {
        "runFunction": "https://myownpersonaldomain.com/mypage?trigger=onEditorsHomepage"
      },
      "onFileScopeGrantedTrigger": {
        "runFunction": "https://myownpersonaldomain.com/mypage?trigger=onFileScopeGrantedEditors"
      }
    },
    "slides": {
      "homepageTrigger": {
        "runFunction": "https://myownpersonaldomain.com/mypage?trigger=onEditorsHomepage"
      },
      "onFileScopeGrantedTrigger": {
        "runFunction": "https://myownpersonaldomain.com/mypage?trigger=onFileScopeGrantedEditors"
      }
    }
  },
  "oauthScopes": [
    "https://www.googleapis.com/auth/calendar.addons.execute",
    "https://www.googleapis.com/auth/calendar.addons.current.event.read",
    "https://www.googleapis.com/auth/calendar.addons.current.event.write",
    "https://www.googleapis.com/auth/drive.addons.metadata.readonly",
    "https://www.googleapis.com/auth/gmail.addons.current.action.compose",
    "https://www.googleapis.com/auth/gmail.addons.current.message.metadata",
    "https://www.googleapis.com/auth/userinfo.email",
    "https://www.googleapis.com/auth/script.external_request",
    "https://www.googleapis.com/auth/script.locale",
    "https://www.googleapis.com/auth/script.scriptapp",
    "https://www.googleapis.com/auth/drive.file",
    "https://www.googleapis.com/auth/documents.currentonly",
    "https://www.googleapis.com/auth/spreadsheets.currentonly",
    "https://www.googleapis.com/auth/presentations.currentonly",
    "https://www.googleapis.com/auth/workspace.linkpreview"
  ]
}

許可清單網址

您可以使用許可清單指定預先核准存取的特定網址 。許可清單有助於保護使用者 data;定義許可清單後,指令碼專案就無法存取 未加入許可清單。

安裝測試部署作業時,這是選填欄位, 您會建立版本化 Deployment

你可以在指令碼或外掛程式執行期間使用許可清單 以下動作:

  • 從外部位置 (例如 HTTPS) 擷取或擷取資訊 端點) 使用 Apps Script UrlFetch 課程中也會快速介紹 Memorystore 這是 Google Cloud 的全代管 Redis 服務如要將網址加入許可清單,以便進行擷取,請在資訊清單檔案中加入 urlFetchWhitelist 欄位。
  • 基於使用者動作開啟或顯示網址 (如果是 會開啟或顯示外部網址的 Google Workspace 外掛程式 Google)。如要將網址加入許可清單以便開啟,請在網頁中加入 addOns.common.openLinkUrlPrefixes 欄位 資訊清單檔案
,瞭解如何調查及移除這項存取權。

將前置字串加入許可清單

在資訊清單檔案中指定許可清單時 (方法是加入 addOns.common.openLinkUrlPrefixesurlFetchWhitelist 欄位),您必須 包含網址前置字元清單您新增至資訊清單的前置字串 必須符合下列規定:

  • 每個前置字串都必須是有效的網址。
  • 每個前置字串都必須使用 https://,而非 http://
  • 每個前置字串都必須有完整網域。
  • 每個前置字串都必須有非空白的路徑。例如:https://www.google.com/ 有效,但 https://www.google.com 不是。
  • 您可以使用萬用字元來比對網址子網域前置字元。
  • 單一 * 萬用字元可用於 addOns.common.openLinkUrlPrefixes 欄位來比對所有連結,但我們不建議這麼做,因為這麼做可能會公開 讓使用者的資料曝露在風險中,並可能導致 外掛程式審核程序。僅限 請在外掛程式功能需要時使用萬用字元。

判斷網址是否與許可清單中的前置字元相符時,請遵循下列規則 套用:

  • 路徑比對會區分大小寫。
  • 如果前置字元與網址相同,則表示比對相符。
  • 如果該網址與前置字元的子網址相同,系統會進行比對。

舉例來說,前置字串 https://example.com/foo 會與下列網址相符:

  • https://example.com/foo
  • https://example.com/foo/
  • https://example.com/foo/bar
  • https://example.com/foo?bar
  • https://example.com/foo#bar

使用萬用字元

您可以使用單一萬用字元 (*) 來比對 urlFetchWhitelistaddOns.common.openLinkUrlPrefixes 只要使用來自這些領域的 小型資料集訓練即可不得使用多個萬用字元來比對多個子網域。 萬用字元必須代表網址的前置字元。

舉例來說,前置字串 https://*.example.com/foo 符合以下字串 網址:

  • https://subdomain.example.com/foo
  • https://any.number.of.subdomains.example.com/foo

前置字串 https://*.example.com/foo「不」與下列字串相符 網址:

  • https://subdomain.example.com/bar (後置字串不相符)
  • https://example.com/foo (至少須有一個子網域)

嘗試儲存資訊清單時,系統會強制執行部分前置字串規則。適用對象 舉例來說,以下前置字元如果出現在 資訊清單。

  • https://*.*.example.com/foo (禁止使用多個萬用字元)
  • https://subdomain.*.example.com/foo (必須使用萬用字元做為開頭前置字元)