Running aGoogle Workspace Add - ons over local HTTP endpoint
I tried to develop a workspace Add-On in a different language and I am completely stuck with this issue. it seems that my add-on does not call my local server endpoint. I get the following error message: "Content can't be loaded (see screenshot https://ibb.co/0VJHqJh)". Furthermore, I can clearly see on my server that my endpoints are not called.
Does Workspace addons support local http endpoint?
Currently, I have:
- a Fastapi server running at http://127.0.0.1:8000 with multiple endpoints.
- each endpoint returns Json CardService. Here a basic endpoint example:
@root_router.get('/homepage', response_class=JSONResponse)
async def homepage(event: object):
print(event)
# return json.dumps(BASIC_CARD)
# return BASIC_CARD
return renderAction
@root_router.post("/homepage2", response_class=JSONResponse)
async def homepage2(event: object):
print(event)
return renderAction
- my add-on is deployed and installed with the following deployments file
{
"oauthScopes": ["https://www.googleapis.com/auth/gmail.addons.execute",
"https://www.googleapis.com/auth/gmail.metadata",
"https://www.googleapis.com/auth/gmail.addons.current.message.metadata",
"https://www.googleapis.com/auth/userinfo.email",
"https://www.googleapis.com/auth/script.external_request",
"https://www.googleapis.com/auth/script.locale",
"https://www.googleapis.com/auth/script.scriptapp",
"https://www.googleapis.com/auth/drive.file",
"https://www.googleapis.com/auth/drive.addons.metadata.readonly"
"https://www.googleapis.com/auth/documents.currentonly",
"https://www.googleapis.com/auth/spreadsheets.currentonly",
"https://www.googleapis.com/auth/presentations.currentonly"],
"addOns": {
"common": {
"name": "My HTTP Add-on",
"logoUrl": "https://fonts.gstatic.com/s/i/googlematerialicons/markunread_mailbox/v6/black-24dp/1x/gm_markunread_mailbox_black_24dp.png",
"homepageTrigger": {
"runFunction": "http://127.0.0.1:8000/homepage"
},
"openLinkUrlPrefixes": ["http://127.0.0.1:8000/homepage"]
},
"gmail": {},
"drive": {},
"calendar": {}
}
}
Thanks in advance for your feedback!
Solution 1:
No because the add-on run on Google servers and they have their own "local endpoint". In other words, http://127.0.0.1
points to the server running the add-on not your machine.
Please bear in mind that the value of homepageTrigger.runFunction
can't be an arbitrary URL, it should be the name of a function. Reference https://developers.google.com/apps-script/manifest/homepage-trigger.
Resources
- https://en.wikipedia.org/wiki/Localhost
- https://developers.google.com/apps-script/manifest/addons?hl=en#Common.FIELDS.openLinkUrlPrefixes