Apps Script "Insufficient Permissions" Error Persisting Despite Extensive Troubleshooting

193 views
Skip to first unread message

Amy Smith

unread,
Jun 23, 2025, 4:38:02 PMJun 23
to Google Apps Script Community

Hi everyone,

I'm experiencing a very frustrating and persistent "Specified permissions are not sufficient" error in my Google Apps Script project, even after trying extensive troubleshooting steps. I'm trying to automate sending emails via Gmail from a Google Sheet, triggered by a checkbox.

The error message I consistently receive is: Exception: Specified permissions are not sufficient to perform the action. Required permissions: (https://mail.google.com/ || https://www.googleapis.com/auth/gmail.readonly || https://www.googleapis.com/auth/gmail.compose || https://www.googleapis.com/auth/gmail.modify)

This happens when the onEdit trigger fires from a checkbox being checked in the Google Sheet.

Here's my setup:

Google Sheet Structure
  • Sheet Name: auto email MVP
  • Tab Name: Sheet1
  • Columns:
    • A: First Name
    • B: Email
    • C: Welcome Email (checkbox)
  • Data: Test name in A2, my test email in B2, checkbox in C2.
Google Apps Script Code (Code.gs)

function onEdit(e) {
  const sheetName = 'Sheet1';
  const checkboxColumn = 3;   // Column C
  const emailColumn = 2;      // Column B
  const firstNameColumn = 1;  // Column A
  const checkboxValue = true;

  const range = e.range;
  const sheet = range.getSheet();

  if (sheet.getName() === sheetName && range.getColumn() === checkboxColumn && range.getValue() === checkboxValue) {
    const row = range.getRow();
    if (row === 1) return; // Skip header row

    const firstName = sheet.getRange(row, firstNameColumn).getValue();
    const recipientEmail = sheet.getRange(row, emailColumn).getValue();

    const templateName = 'Welcome_Email_Template'; // This Gmail template exists and is named correctly
    const bodyPlaceholder = '{{FIRST_NAME}}';

    try {
      const drafts = GmailApp.getDrafts();
      const draft = drafts.find(d => d.getMessage().getSubject().includes(templateName));

      if (!draft) {
        Logger.log(`Template "${templateName}" not found in drafts. Please create a Gmail template named "${templateName}".`);
        return;
      }

      const templateMessage = draft.getMessage();
      let subject = templateMessage.getSubject().replace(templateName, '').trim();
      let body = templateMessage.getBody();

      body = body.replace(new RegExp(bodyPlaceholder, 'g'), firstName);

      GmailApp.sendEmail(recipientEmail, subject, body, {
        htmlBody: body
      });
      Logger.log(`Welcome email sent to ${recipientEmail} for ${firstName}.`);

      // Optional: Uncomment to uncheck the box after sending
      // sheet.getRange(row, checkboxColumn).setValue(false);

    } catch (error) {
      Logger.log(`Error sending email for ${firstName}: ${error.toString()}`);
    }
  }
}

  Manifest File (appsscript.json)

  {
  "timeZone": "Pacific/Auckland",
  "dependencies": {},
  "exceptionLogging": "STACKDRIVER",
  "runtimeVersion": "V8",
  "oauthScopes": [
    "https://www.googleapis.com/auth/spreadsheets",
    "https://www.googleapis.com/auth/script.send_mail",
    "https://www.googleapis.com/auth/gmail.compose",
    "https://www.googleapis.com/auth/gmail.modify",
    "https://www.googleapis.com/auth/gmail.readonly",
    "https://mail.google.com/"
  ]
}

Troubleshooting Steps Attempted (Unsuccessfully)

I have tried all of the following, on two separate free Gmail accounts, with consistent failure:

  1. Explicit oauthScopes: Ensured appsscript.json contains all the required Gmail and Sheets scopes as listed in the error message and Google documentation.
  2. Multiple Authorization Attempts: Ran the script directly from the Apps Script editor (via a temporary helper function forceGmailAuth which was later removed) to trigger the authorization flow. Each time, the consent screen appeared, and I explicitly selected/allowed all requested permissions.
  3. Project Renaming: Renamed the Apps Script project to force a new authorization context, followed by re-authorization.
  4. Revoking Access: Went to Google Account security settings and explicitly removed access for the Apps Script project before attempting re-authorization each time.
  5. Browser & Computer Reset: Cleared Chrome's cache and cookies ("All time"), performed a full computer shutdown and restart, and then re-logged in.
  6. Verification of Gmail Template: Confirmed the Welcome_Email_Template exists and is named exactly as in the script.

Despite all these steps, the "Specified permissions are not sufficient" error persists, indicating the permissions are somehow not "sticking" or being recognized by Google's system.

Has anyone encountered such a persistent authorization issue with Apps Script on a free Gmail account, and if so, what was the resolution? Any insights or further diagnostic steps would be greatly appreciated.

Scott Bennett

unread,
Jun 23, 2025, 4:59:51 PMJun 23
to google-apps-sc...@googlegroups.com
Just a guess, but you probably need to use an installable trigger not a simple trigger. 
Scott Bennett


Sent from my iPhone 

On Jun 23, 2025, at 3:38 PM, Amy Smith <amy.smi...@gmail.com> wrote:


--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/google-apps-script-community/cc5b7446-ad9c-4d0b-96b6-ba6619bba82en%40googlegroups.com.

George Ghanem

unread,
Jun 23, 2025, 7:33:43 PMJun 23
to google-apps-sc...@googlegroups.com

You can not use the simple trigger to do this. You will have to define a trigger and authorize the software to do this function.

Also rename the onEdit function to something else so that it does not confuse the simple trigger versus the defined trigger.


Amy Smith

unread,
Jun 24, 2025, 5:34:25 AMJun 24
to Google Apps Script Community
Thanks guys, you were correct I had to use an installable trigger not a simple trigger.

George Ghanem

unread,
Jun 24, 2025, 1:22:08 PMJun 24
to google-apps-sc...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages