Reputation: 128
About a week ago the Alternative Runtime was released to the public (general documentation)
I am currently developing in Node.js. What I hope to achieve is that upon opening the add-on in a Google Document (or some button click), I can obtain the Docs document id of the document that is currently open and manipulate the document with the Google Docs API.
After fiddling, I managed to receive the payload for the 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) I would be given the Docs document id, so I could start using the Docs API and manipulate the document.
My second attempt for obtaining the Docs document id was to not use homepageTrigger
but to use OnFileScopeGrantedTrigger
. However, this required me to use the CardService. A new Card Framework based on JSON does exist for Alternative Runtimes, but I could not find any way of achieving the following with JSON:
CardService.newEditorFileScopeActionResponseBuilder() .requestFileScopeForActiveDocument().build();
(source documentation for the code above).
TLDR: How can I obtain the Docs document id of the currently opened Google Docs document with my add-on that is based on the new Alternative Runtimes?
Upvotes: 0
Views: 256
Reputation: 92
Google's documentation is just the worst, I was wondering the same thing. Below is the snippet for returning a JSONified response in Express that builds the prompt to authorize the document.
Basically, this is what helps you with defining your response object here: https://developers.google.com/workspace/add-ons/reference/rpc/google.apps.card.v1
res.json({
renderActions: {
hostAppAction: {
editorAction: {
requestFileScopeForActiveDocument: {},
},
},
},
});
Upvotes: 1