2

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).

10
  • 2
    Review " Taking advantage of webapps". See tag info page for more details. Commented Nov 28, 2024 at 8:11
  • I also want to check, if what is the current Delopyment Settings. Commented Nov 28, 2024 at 8:33
  • @Babanana, here is deployment setting: I have deployed as web app + add-on Execute as : me Who has access : Anyone within Organisation as I need to select web app +add-on beacuse web app provide me url for external access and add-on is for building an add-on for Gmail(connector). Commented Nov 28, 2024 at 10:43
  • I have very limited information with your current project, however I am experiencing the same thing before with "Anyone within Organisation" which causes some problems with authentication. If you change it to Anyone who has a Google Account it fixes it. Commented Nov 28, 2024 at 11:46
  • Basically I am triggering my web app from external scheduler job via service account. So in my service account I have generated json key which I am using to authenticate external request from scheduler job. Commented Nov 28, 2024 at 13:49

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.