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:
- Explicit oauthScopes: Ensured appsscript.json contains all the required Gmail and Sheets scopes as listed in the error message and Google documentation.
- 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.
- Project Renaming: Renamed the Apps Script project to force a new authorization context, followed by re-authorization.
- Revoking Access: Went to Google Account security settings and explicitly removed access for the Apps Script project before attempting re-authorization each time.
- Browser & Computer Reset: Cleared Chrome's cache and cookies ("All time"), performed a full computer shutdown and restart, and then re-logged in.
- 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.