Google Workspace 부가기능 매니페스트

Apps Script 프로젝트는 매니페스트 파일을 사용하여 스크립트와 그 작업에 대한 특정 세부정보를 구성합니다. 매니페스트를 보고 수정하는 방법은 매니페스트를 참고하세요.

이 문서에서는 Google Workspace 부가기능의 매니페스트 구성에 대해 자세히 설명합니다.

Google Workspace 부가기능의 매니페스트 구조

Google Workspace 부가기능은 Apps Script 프로젝트 매니페스트 파일을 사용하여 부가기능의 모양과 동작의 여러 측면을 정의합니다. Google Workspace 부가기능의 매니페스트 속성은 매니페스트 객체 구조의 addOns 섹션 아래에 구성됩니다.

샘플 Google Workspace 부가기능 매니페스트 구성

다음 매니페스트 샘플은 다음과 같은 측면을 포함하여 Google Workspace 부가기능을 정의하는 매니페스트 파일의 섹션을 보여줍니다.

  • 매니페스트의 addOns.common 섹션은 부가기능의 이름, 로고 URL, 색상 및 기타 일반적인 호스트 독립적 설정을 정의합니다.
  • 매니페스트는 공통 홈페이지를 정의할 뿐만 아니라 캘린더, 드라이브, 문서, 스프레드시트, 프레젠테이션 관련 홈페이지도 정의합니다. Gmail은 기본 홈페이지를 사용합니다.
  • 샘플 매니페스트 설정은 다음을 사용 설정합니다.
    • 캘린더 eventOpeneventUpdated 트리거와 2개의 캘린더 회의 솔루션.
    • 보편적인 작업 두 가지
    • Drive onItemsSelectedTrigger
    • Gmail 편지쓰기 작업 및 상황별 트리거입니다.
    • 문서 linkPreviewTrigger. 이 트리거에 관한 자세한 내용은 스마트 칩이 포함된 링크 미리보기를 참고하세요.
    • Docs, Sheets, Slides용 파일별 인터페이스
  • oauthScopes 필드는 프로젝트의 승인 범위를 설정합니다 (일반적으로 부가기능에 필요).
  • urlFetchWhitelist 필드는 가져온 엔드포인트가 지정된 HTTPS URL 프리픽스 목록과 일치하는지 확인하는 필드입니다. 자세한 내용은 허용 목록 URL을 참고하세요.

샘플의 링크는 매니페스트 참조 문서의 해당 필드에 관한 설명으로 연결됩니다.

{
  "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://en.wikipedia.org/wiki/",
        "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"
        }
      ]
    },
    "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/"
  ]
}

URL 허용 목록

허용 목록을 사용하면 스크립트 또는 부가기능의 액세스를 위해 사전 승인된 특정 URL을 지정할 수 있습니다. 허용 목록은 사용자 데이터를 보호하는 데 도움이 됩니다. 허용 목록을 정의하면 스크립트 프로젝트는 허용 목록에 없는 URL에 액세스할 수 없습니다.

이 필드는 테스트 배포를 설치하는 경우에는 선택사항이지만 버전이 지정된 배포를 만들 때는 필수입니다.

스크립트 또는 부가기능이 다음 작업을 실행할 때 허용 목록을 사용합니다.

  • Apps Script UrlFetch 서비스를 사용하여 외부 위치 (예: HTTPS 엔드포인트)에서 정보를 검색하거나 가져옵니다. URL을 가져오도록 허용 목록에 추가하려면 매니페스트 파일에 urlFetchWhitelist 필드를 포함합니다.
  • 사용자 작업에 대한 응답으로 URL을 열거나 표시합니다 (Google 외부의 URL을 열거나 표시하는 Google Workspace 부가기능에 필요). URL이 열리도록 허용 목록에 추가하려면 매니페스트 파일에 addOns.common.openLinkUrlPrefixes 필드를 포함합니다.

허용 목록에 프리픽스 추가

매니페스트 파일에서 addOns.common.openLinkUrlPrefixes 또는 urlFetchWhitelist 필드를 포함하여 허용 목록을 지정할 때는 URL 프리픽스 목록을 포함해야 합니다. 매니페스트에 추가하는 프리픽스는 다음 요구사항을 충족해야 합니다.

  • 각 접두사는 유효한 URL이어야 합니다.
  • 각 프리픽스는 http://가 아닌 https://를 사용해야 합니다.
  • 각 프리픽스에는 전체 도메인이 있어야 합니다.
  • 각 접두사에는 비어 있지 않은 경로가 있어야 합니다. 예를 들어 https://www.google.com/는 유효하지만 https://www.google.com는 유효하지 않습니다.
  • 와일드 카드를 사용하여 URL 하위 도메인 프리픽스와 일치시킬 수 있습니다.
  • addOns.common.openLinkUrlPrefixes 필드에 단일 * 와일드 카드를 사용하여 모든 링크를 일치시킬 수 있지만, 사용자의 데이터가 위험에 노출될 수 있고 부가기능 검토 프로세스가 지연될 수 있으므로 이 방법은 권장되지 않습니다. 부가기능 기능에 와일드 카드가 필요한 경우에만 와일드 카드를 사용하세요.

URL이 허용 목록에 포함된 프리픽스와 일치하는지 확인할 때는 다음 규칙이 적용됩니다.

  • 경로 일치는 대소문자를 구분합니다.
  • 접두어가 URL과 동일하면 일치하는 것으로 간주됩니다.
  • URL이 접두사와 같거나 하위이면 일치입니다.

예를 들어 접두사 https://example.com/foo는 다음 URL과 일치합니다.

  • 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 필드의 하위 도메인과 일치시킬 수 있습니다. 두 개 이상의 와일드 카드를 사용하여 여러 하위 도메인과 일치시킬 수 없으며, 와일드 카드는 URL의 선행 접두사를 나타내야 합니다.

예를 들어 프리픽스 https://*.example.com/foo는 다음 URL과 일치합니다.

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

프리픽스 https://*.example.com/foo는 다음 URL과 일치하지 않습니다.

  • https://subdomain.example.com/bar (서픽스 불일치)
  • https://example.com/foo (하위 도메인이 하나 이상 있어야 함)

매니페스트를 저장하려고 할 때 일부 접두사 규칙이 적용됩니다. 예를 들어 저장을 시도할 때 매니페스트에 다음 프리픽스가 있으면 오류가 발생합니다.

  • https://*.*.example.com/foo (와일드 카드 여러 개는 금지됨)
  • https://subdomain.*.example.com/foo(와일드 카드는 선행 접두사로 사용해야 함)