#I m struggling to send get requests to
1 messages · Page 1 of 1 (latest)
Unless a web app is deployed with "Anyone" access, you can't directly send requests to it. Web apps that require the user to sign in don't accept requests, even with OAuth credentials attached.
If you want to trigger an Apps Script function that does require authentication, you need to use the Apps Script REST API, which is a bit more complicated to setup: https://developers.google.com/apps-script/api/how-tos/execute
So when the documentation here refers to a "get request" they don't mean the kind that the python requests library makes? https://developers.google.com/apps-script/guides/content
Ok, I think I'm starting to understand. It was pretty easy to get my browser to show the result of the doGet() function. Your saying that if I want to send requests to it programatically, I have to deploy the script as an API exectuable, and do all the other steps in "Execute Functions" documentation
Also, I noticed that you created a thread: thank you for showing me that was a thing! I should be doing that!
Yep, you got it. Your browser passes cookies that let's Apps Script know who you are, but to do that programatically requires that extra legwork.
Happy to help!
I am attempting to execute the python code snippet provided here: https://developers.google.com/apps-script/api/how-tos/execute#api_request_examples
The way I'm dealing with authorization in my add-on, is that I get sent an authorization token when the user interacts with widgets. So instead of creds, _ = google.auth.default(), I am using creds = credentials.Credentials(token='the access token I extracted')
Unfortunately, I end up with an error with "reason": "ACCESS_TOKEN_SCOPE_INSUFFICIENT"
I think I need to add more scopes to my deployment resource in the 'Google Workspace Add-ons API for alternate runtimes' tab, but I'm not sure what scopes to add. I am trying to follow the instructions, and add all the scopes that my app scripts uses, but in the overview, it only says "No scopes are requested for this deployment". So maybe I need to change my apps-script so that it requires more scopes?
I tried adding one of the scopes my token already has to the appscript manifest file, but no luck yet.
I think it needs to be one of these! https://developers.google.com/apps-script/api/reference/rest/v1/scripts/run#authorization-scopes
After changing my scopes, I was able to get a new error: "code": 404,\n "message": "Requested entity was not found."
So now I'm double checking the name of the function in my request, the script id, etc
Success, seemingly! The 404 went away when I substituted the deployment id for the script id