首页 > 解决方案 > 如何开始测试我的 Google Drive UI 集成?

问题描述

我开始开发 Google Drive UI 集成,但我遇到了一个相当基本的问题。我找不到开始测试我的集成的选项。

到目前为止,我已经完成了以下工作:

我还需要做什么才能让我的集成显示在 Google 云端硬盘中?我可以将已发布的公共插件添加到我的 Google Drive,但由于某种原因,我无法开始使用我的新项目。我在哪里可以找到它?

标签: google-drive-api

解决方案


回答

两种类型的附加组件

由于您的加载项是an add-on that simply opens a document in our web app您正在寻找工作区加载项,因此为了在不使用 G-Suite 域的情况下手动安装您的加载项。您应该按照本快速入门中的说明从清单部署您的 Apps 脚本项目。

请记住,之前的快速入门遵循的是旧版 Apps 脚本编辑器。此示例有一个清单文件示例appsscript.json,如下所示:

{
  "timeZone": "America/New_York",
  "dependencies": {
  },
  "exceptionLogging": "STACKDRIVER",
  "oauthScopes": [
    "https://www.googleapis.com/auth/calendar.addons.execute",
    "https://www.googleapis.com/auth/calendar.readonly",
    "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.readonly",
    "https://www.googleapis.com/auth/gmail.addons.execute",
    "https://www.googleapis.com/auth/script.locale"],
  "runtimeVersion": "DEPRECATED_ES5",
  "addOns": {
    "common": {
      "name": "Cats",
      "logoUrl": "https://www.gstatic.com/images/icons/material/system/1x/pets_black_48dp.png",
      "useLocaleFromApp": true,
      "homepageTrigger": {
        "runFunction": "onHomepage",
        "enabled": true
      },
      "universalActions": [{
        "label": "Learn more about Cataas",
        "openLink": "https://cataas.com"
      }]
    },
    "gmail": {
      "contextualTriggers": [{
        "unconditional": {
        },
        "onTriggerFunction": "onGmailMessage"
      }],
      "composeTrigger": {
        "selectActions": [{
          "text": "Insert cat",
          "runFunction": "onGmailCompose"
        }],
        "draftAccess": "NONE"
      }
    },
    "drive": {
      "onItemsSelectedTrigger": {
        "runFunction": "onDriveItemsSelected"
      }
    },
    "calendar": {
      "eventOpenTrigger": {
        "runFunction": "onCalendarEventOpen"
      }
    }
  }
}

oauthScopes将为每个应用程序请求权限,addOns.common将为下面定义的所有服务定义通用参数,例如addOns.drive。在 Drive 服务中,您将看到onItemsSelectedTrigger将处理选择项目的事件,并将运行之前在快速入门示例中定义的onDriveItemsSelected函数。您可以在此处查看所有相关的事件触发器。

安装插件后,它将显示在manifest 中定义的每个服务的 UI 中。请记住,这只是一个自我安装教程,您应该按照本教程发布您的附加组件,以便其他人能够安装它。


推荐阅读