如何在 Alternative Runtime Docs Add-on 中获取 Google Docs 文档标识符
How to obtain Google Docs document identifier in Alternative Runtime Docs Add-on
大约一周前,Alternative Runtime 发布到 public (general documentation)
我目前正在 Node.js 开发。我希望实现的是,在 Google 文档(或单击某些按钮)中打开加载项后,我可以获得当前打开的文档的 Docs 文档 ID,并使用 Google 文档 API.
摆弄之后,我设法收到了 homepageTrigger
(documentation). In the body, I do get multiple tokens but unfortunately, the docs
field is empty. My first assumption was that when requesting the scope documents.currentonly
(documentation) 的有效负载,我将获得 Docs 文档 ID,因此我可以开始使用 Docs API 和操作文档。
我第二次尝试获取 Docs 文档 ID 时没有使用 homepageTrigger
,而是使用了 OnFileScopeGrantedTrigger
。但是,这需要我使用 CardService。替代运行时确实存在一个新的 Card Framework based on JSON,但我找不到任何方法来使用 JSON 实现以下目标:
CardService.newEditorFileScopeActionResponseBuilder() .requestFileScopeForActiveDocument().build();
(source documentation for the code above).
TLDR: 如何获取当前打开的 Google Docs 文档的 Docs 文档 ID 以及基于新的替代运行时的加载项?
Google 的文档是最糟糕的,我也在想同样的事情。
下面是在 Express 中返回 JSONified 响应的代码片段,它构建了授权文档的提示。
基本上,这可以帮助您在此处定义响应对象:
https://developers.google.com/workspace/add-ons/reference/rpc/google.apps.card.v1
res.json({
renderActions: {
hostAppAction: {
editorAction: {
requestFileScopeForActiveDocument: {},
},
},
},
});
大约一周前,Alternative Runtime 发布到 public (general documentation)
我目前正在 Node.js 开发。我希望实现的是,在 Google 文档(或单击某些按钮)中打开加载项后,我可以获得当前打开的文档的 Docs 文档 ID,并使用 Google 文档 API.
摆弄之后,我设法收到了 homepageTrigger
(documentation). In the body, I do get multiple tokens but unfortunately, the docs
field is empty. My first assumption was that when requesting the scope documents.currentonly
(documentation) 的有效负载,我将获得 Docs 文档 ID,因此我可以开始使用 Docs API 和操作文档。
我第二次尝试获取 Docs 文档 ID 时没有使用 homepageTrigger
,而是使用了 OnFileScopeGrantedTrigger
。但是,这需要我使用 CardService。替代运行时确实存在一个新的 Card Framework based on JSON,但我找不到任何方法来使用 JSON 实现以下目标:
CardService.newEditorFileScopeActionResponseBuilder() .requestFileScopeForActiveDocument().build();
(source documentation for the code above).
TLDR: 如何获取当前打开的 Google Docs 文档的 Docs 文档 ID 以及基于新的替代运行时的加载项?
Google 的文档是最糟糕的,我也在想同样的事情。 下面是在 Express 中返回 JSONified 响应的代码片段,它构建了授权文档的提示。
基本上,这可以帮助您在此处定义响应对象: https://developers.google.com/workspace/add-ons/reference/rpc/google.apps.card.v1
res.json({
renderActions: {
hostAppAction: {
editorAction: {
requestFileScopeForActiveDocument: {},
},
},
},
});