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

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

Google Calendar Workspace Add-on function not invoked

问题

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

清单 (appsscript.json):

  1. {
  2. "timeZone": "Europe/Berlin",
  3. "dependencies": {
  4. "enabledAdvancedServices": []
  5. },
  6. "exceptionLogging": "STACKDRIVER",
  7. "oauthScopes": [
  8. "https://www.googleapis.com/auth/calendar.addons.execute",
  9. "https://www.googleapis.com/auth/calendar.readonly",
  10. "https://www.googleapis.com/auth/drive.addons.metadata.readonly",
  11. "https://www.googleapis.com/auth/gmail.addons.current.action.compose",
  12. "https://www.googleapis.com/auth/gmail.addons.current.message.readonly",
  13. "https://www.googleapis.com/auth/gmail.addons.execute",
  14. "https://www.googleapis.com/auth/script.locale"
  15. ],
  16. "runtimeVersion": "V8",
  17. "addOns": {
  18. "common": {
  19. "name": "Cats",
  20. "logoUrl": "https://www.gstatic.com/images/icons/material/system/1x/pets_black_48dp.png",
  21. "useLocaleFromApp": true,
  22. "homepageTrigger": {
  23. "runFunction": "onHomepage",
  24. "enabled": true
  25. },
  26. "universalActions": [
  27. {
  28. "label": "Learn more about Cataas",
  29. "openLink": "https://cataas.com"
  30. }
  31. ]
  32. },
  33. "gmail": {
  34. "contextualTriggers": [
  35. {
  36. "unconditional": {},
  37. "onTriggerFunction": "onGmailMessage"
  38. }
  39. ],
  40. "composeTrigger": {
  41. "selectActions": [
  42. {
  43. "text": "Insert cat",
  44. "runFunction": "onGmailCompose"
  45. }
  46. ],
  47. "draftAccess": "NONE"
  48. }
  49. },
  50. "drive": {
  51. "onItemsSelectedTrigger": {
  52. "runFunction": "onDriveItemsSelected"
  53. }
  54. },
  55. "calendar": {
  56. "eventOpenTrigger": {
  57. "runFunction": "onCalendarEventOpen"
  58. },
  59. "eventUpdateTrigger": {
  60. "runFunction": "onCalendarEventUpdate"
  61. },
  62. "currentEventAccess": "READ"
  63. }
  64. }
  65. }

函数:

  1. function onCalendarEventOpen(e) {
  2. console.log(e);
  3. console.log("CALENDAR-EVENT-OPEN!!!")
  4. }
  5. function onCalendarEventUpdate(e) {
  6. console.log("CALENDAR-EVENT-UPDATE!!!")
  7. }

执行选项卡的屏幕截图(仅显示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):

  1. {
  2. "timeZone": "Europe/Berlin",
  3. "dependencies": {
  4. "enabledAdvancedServices": []
  5. },
  6. "exceptionLogging": "STACKDRIVER",
  7. "oauthScopes": [
  8. "https://www.googleapis.com/auth/calendar.addons.execute",
  9. "https://www.googleapis.com/auth/calendar.readonly",
  10. "https://www.googleapis.com/auth/drive.addons.metadata.readonly",
  11. "https://www.googleapis.com/auth/gmail.addons.current.action.compose",
  12. "https://www.googleapis.com/auth/gmail.addons.current.message.readonly",
  13. "https://www.googleapis.com/auth/gmail.addons.execute",
  14. "https://www.googleapis.com/auth/script.locale"
  15. ],
  16. "runtimeVersion": "V8",
  17. "addOns": {
  18. "common": {
  19. "name": "Cats",
  20. "logoUrl": "https://www.gstatic.com/images/icons/material/system/1x/pets_black_48dp.png",
  21. "useLocaleFromApp": true,
  22. "homepageTrigger": {
  23. "runFunction": "onHomepage",
  24. "enabled": true
  25. },
  26. "universalActions": [
  27. {
  28. "label": "Learn more about Cataas",
  29. "openLink": "https://cataas.com"
  30. }
  31. ]
  32. },
  33. "gmail": {
  34. "contextualTriggers": [
  35. {
  36. "unconditional": {},
  37. "onTriggerFunction": "onGmailMessage"
  38. }
  39. ],
  40. "composeTrigger": {
  41. "selectActions": [
  42. {
  43. "text": "Insert cat",
  44. "runFunction": "onGmailCompose"
  45. }
  46. ],
  47. "draftAccess": "NONE"
  48. }
  49. },
  50. "drive": {
  51. "onItemsSelectedTrigger": {
  52. "runFunction": "onDriveItemsSelected"
  53. }
  54. },
  55. "calendar": {
  56. "eventOpenTrigger": {
  57. "runFunction": "onCalendarEventOpen"
  58. },
  59. "eventUpdateTrigger": {
  60. "runFunction": "onCalendarEventUpdate"
  61. },
  62. "currentEventAccess": "READ"
  63. }
  64. }
  65. }

functions:

  1. function onCalendarEventOpen(e) {
  2. console.log(e);
  3. console.log("CALENDAR-EVENT-OPEN!!!")
  4. }
  5. function onCalendarEventUpdate(e) {
  6. console.log("CALENDAR-EVENT-UPDATE!!!")
  7. }

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

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

  1. 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:

  1. 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:

确定