Execute web app with Gmail access as user who executes the script

I started quite recently experimenting with web apps, and I am now busy getting them to run across accounts within my organization.

I need to update labels to Gmail emails across these accounts. I trigger my scripts via a get request in the client details spreadsheet, which identifies the email threads in the associated accounts and applies them a label.

For this to work without having to create a web app per account executed as the owner of the account, I imagined that a deployment executed as the user who executes the trigger would just do it. However, doing so results in an html response that seems to be an authorization screen from Google:

-------------------------------------

<html><head><title>Authorization needed

Google Apps Script"><h1 class="project-name">My app name (Unverified)</h1><p class="auth-prompt">The developer of <strong class="overflow-protected"> My app name</strong>, <a href="mailto:florent@xxx.de">florent@xxx.de</a>, needs your permission to access your data on Google

When reviewing permissions, consider whether you trust <strong class="overflow-protected">

 Execution canceled. You may now close the tab/window or <a id="auth-cancel-link" href="">reload the page</a>

('auth-button-cancel').onclick = showAuthCancel; document.getElementById('auth-button-confirm').onclick = showAuthPrompt; document.getElementById('auth-cancel-link').onclick = showAuthRequired

-------------------------------------

It works fine when the app is run as myself, but Iโ€™d hate to have to replicate and maintain the project on each account, even though that is a way to achieve the result.

I read a number of articles, but many did not apply to my situation, and others were beyond my current skill to try them all out. I also tried a few things in the cloud console but I am too noob to get my head around it fully.

 

I use the following oAuth scopes and don't see what can be missing:

```
"oauthScopes": [
"https://www.googleapis.com/auth/script.external_request",
"https://www.googleapis.com/auth/script.scriptapp",
"https://www.googleapis.com/auth/forms",
"https://www.googleapis.com/auth/drive.readonly",
"https://www.googleapis.com/auth/spreadsheets",
"https://www.googleapis.com/auth/userinfo.email",
"https://www.googleapis.com/auth/script.external_request",
"https://www.googleapis.com/auth/gmail.labels",
"https://www.googleapis.com/auth/gmail.modify"
```

],
```

0 0 307
0 REPLIES 0
Top Solution Authors