#I m struggling to send get requests to

1 messages · Page 1 of 1 (latest)

graceful owl
#

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.

copper ridge
#

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!

graceful owl
#

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!

copper ridge
#

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?

copper ridge
#

I tried adding one of the scopes my token already has to the appscript manifest file, but no luck yet.

#

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

copper ridge
#

Success, seemingly! The 404 went away when I substituted the deployment id for the script id