英文:
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,没有日历相关的内容):
日志资源管理器的屏幕截图(再次只显示Gmail,没有尝试触发日历的日志):
英文:
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):
Screenshot of Logs Explorer (again only Gmail, no logs from attempts to trigger in Calendar)
答案1
得分: 2
似乎您没有足够的访问权限。您还应该添加以下范围:
https://www.googleapis.com/auth/calendar.addons.current.event.read
此外,您必须打开插件才能运行代码,请确保在执行任何操作之前单击侧边栏中的图标,以触发您的函数:
英文:
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:
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论