Google日历Workspace附加功能未被调用。

huangapple go评论70阅读模式
英文:

Google Calendar Workspace Add-on function not invoked

问题

我已经按照这个指南设置了一个日历插件,并使其运行起来。Gmail的函数被调用并正常工作,但是日历功能根本没有被调用 - 也就是说,我在AppsScript编辑器中看到了onGmailCompose的执行,类型为Add-on,但是没有看到onCalendarEventOpen的执行。在日志资源管理器中也没有与日历相关的日志。

清单 (appsscript.json):

{
  "timeZone": "Europe/Berlin",
  "dependencies": {
    "enabledAdvancedServices": []
  },
  "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": "V8",
  "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"
      },
      "eventUpdateTrigger": {
        "runFunction": "onCalendarEventUpdate"
      },
      "currentEventAccess": "READ"
    }
  }
}

函数:

function onCalendarEventOpen(e) {
  console.log(e);
  console.log("CALENDAR-EVENT-OPEN!!!")  
}

function onCalendarEventUpdate(e) {
  console.log("CALENDAR-EVENT-UPDATE!!!")
}

执行选项卡的屏幕截图(仅显示Gmail,没有日历相关的内容):
Google日历Workspace附加功能未被调用。

日志资源管理器的屏幕截图(再次只显示Gmail,没有尝试触发日历的日志):
Google日历Workspace附加功能未被调用。

英文:

I have followed this guide to get a Calendar add-on up and running. The functions for Gmail are invoked and working correctly, but the Calendar function is not invoked at all - i.e. I see Executions of onGmailCompose, type Add-on in the AppsScript editor, but none for onCalendarEventOpen. Nothing for Calendar in the Logs Explorer either.

Manifest (appsscript.json):

{
  "timeZone": "Europe/Berlin",
  "dependencies": {
    "enabledAdvancedServices": []
  },
  "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": "V8",
  "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"
      },
      "eventUpdateTrigger": {
        "runFunction": "onCalendarEventUpdate"
      },
      "currentEventAccess": "READ"
    }
  }
}

functions:

function onCalendarEventOpen(e) {
  console.log(e);
  console.log("CALENDAR-EVENT-OPEN!!!")  
}

function onCalendarEventUpdate(e) {
  console.log("CALENDAR-EVENT-UPDATE!!!")
}

Screenshot of Executions tab (only Gmail, nothing for Calendar):
Google日历Workspace附加功能未被调用。

Screenshot of Logs Explorer (again only Gmail, no logs from attempts to trigger in Calendar)
Google日历Workspace附加功能未被调用。

答案1

得分: 2

似乎您没有足够的访问权限。您还应该添加以下范围:

https://www.googleapis.com/auth/calendar.addons.current.event.read

此外,您必须打开插件才能运行代码,请确保在执行任何操作之前单击侧边栏中的图标,以触发您的函数:

Google日历Workspace附加功能未被调用。

英文:

Looks like you don't have sufficient access. You should also add the scope:

https://www.googleapis.com/auth/calendar.addons.current.event.read

Additionally, you must have the plug-in open for the code to run, so make sure you click its icon in the sidebar before performing any operations you expect to trigger your functions:

Google日历Workspace附加功能未被调用。

huangapple
  • 本文由 发表于 2023年6月26日 17:59:18
  • 转载请务必保留本文链接:https://go.coder-hub.com/76555591.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定