I am using a Service Account with domain-wide delegation and have set the necessary OAuth scopes for the script. However, despite these efforts, I consistently receive a 401 Unauthorized error when the trigger is invoked.
Verified that the Service Account has been granted the required permissions and scopes. Also used Google Cloud Scheduler and Pub/Sub. These tools are configured to trigger my deployed Google Apps Script web app's doPost method every 5 minutes.
Confirmed that the deployed Google Apps Script web app is accessible via its public URL and responds correctly to authorized requests.
Attempted to pass the Authorization: Bearer header when making requests to the doPost method. Here is deployment details :
On the Script Editor:
Deployed as Web App + add-on. Create new Project version At Execute the app as, select "your account" At Who has access to the app, select "Anyone within Organisation" Click "Deploy" Copy "Current web app URL" Click "OK" got the deployed web app url and deploymentid. Now I have published connector with google workspace marketplace sdk with the deployed deploymentid. But when checked webapp url even on postman getting response as 401 unauthorized.
I would appreciate specific technical guidance or code snippets that can help resolve the 401 Unauthorized issue or provide an alternative approach for achieving frequent triggers(every 5 minutes).