Feb 04, 2021 09:08 AM
Hi all,
Brief: I am trying to use the Google API to run a script on Google Apps Script (GAS) from a scripting block. Has anyone accomplished this? I read through this thread and decided to pull data into GAS from the Google side, but my client wants me to handle it from Airtable.
Full Explanation:
I am new to Airtable and am developing a script that will scrape a website for video metrics. I saw in Airtable’s docs that direct DOM manipulations allowed in vanilla JS are excluded, so I decided to stick with a script I already had in GAS to perform the task.
I saw Bill’s in-depth response at the link above and decided to run the processes from Google for simplicity, as the Airtable API is a lot nicer to work with (i.e. pulling data into GAS) than pushing data to GAS from Airtable using the Google API, which requires Oauth2.
The group I am building the project for, however, wants me to make an API call to GAS from Airtable, call Urlfetchapp in GAS, and send the data back to Airtable to finish table manipulation there. They are claiming that they want as much of the code to be in Airtable so that they can use Airtable’s UI wherever possible. I have spent some time banging my head on the wall trying to get Oauth2 set up with the Google REST API, since I can’t use the gapi library (would need to use some of the workarounds discussed here and the library is likely too big for those). After that, I considered working directly with the Oauth2 endpoints as described by Google here, but that appears to require DOM manipulation if I am to avoid CORS issues. Sigh.
What I see as my options:
I would greatly appreciate if someone with more Airtable experience could chime in here. I saw that custom blocks – now Airtable apps? – might be the way to go, as mentioned by Bill on the aforementioned thread. Not confident with React, so I would like to avoid this if possible.
Thank you!
Feb 04, 2021 09:34 AM
Hi JB, and welcome to the community!
Yes - many times. Lots to share but I don’t have time to write it today - call me as soon as you can at 970-389-3126 before someone else does. :winking_face:
Feb 04, 2021 03:58 PM
Thanks for the help earlier, Bill.
For any future readers, Bill and I discussed deploying my script as a Web App and using webhooks (doPost()) to get the job done, which is working for me.
Unfortunately, this thread discusses the limitations of this approach, namely, that fetch’s inability to handle redirects means that POST requests will fail even if the script runs:
Bill: I assume this means I have no choice but to use the Airtable API to update the table from my script, since there will be no return object?
Feb 04, 2021 04:48 PM
I believe this is an accurate statement given that an oAuth-based API call from the script action is not possible and any return values from the Google Apps Script webhook is not possible. Note that return values do work fine in Airtable fetch calls if it’s not a Google Apps Script webhook server you are calling. This includes other Google SDKs such as Maps, etc. As far as I know, the inability to follow redirects is only an issue with Google Apps Script web services.
Another risk factor (for other readers) that we discussed is the possibility that the volume of actions could exceed the monthly quota. Just sayin’ …
All of these challenges conspire to intimate it may be better in some cases to use pure script triggers in Google Apps Script and forget about Airtable script altogether. One advantage of this approach is to sustain all integration logic separate and apart from Airtable in case you ever need to change database horses.
Apr 05, 2023 02:28 PM
Try using an automation to trigger creation of a new row in a connected google sheet, then within that google sheet set up an event based trigger that will run a script when the sheet is changed.