I have a google sheet page that when an entry is updated or inserted it updates or inserts into a mysql DB. Now this has been working fine up until recently. Now the only thing it does is error out with the following
Exception: You do not have permission to call ScriptApp.getProjectTriggers. Required permissions: https://www.googleapis.com/auth/script.scriptapp
at createOrUpdateTrigger(database_connect:31:30)```
I have reauth this many times but still get the same error in the logs.
My Manifest
{
"timeZone": "America/New_York",
"dependencies": {
"enabledAdvancedServices": []
},
"oauthScopes": [
"https://www.googleapis.com/auth/spreadsheets.readonly",
"https://www.googleapis.com/auth/userinfo.email",
"https://www.googleapis.com/auth/script.external_request"
],
"exceptionLogging": "STACKDRIVER",
"runtimeVersion": "V8"
}
I have tried updating my function and changing the scopes. Everything I read says to go to project properties and adding the scope. This option is not available anywhere i can see.
function updateDatabaseRow(row) {
// Replace with your Google Sheet ID and sheet name
const SHEET_ID = 'MyInfo';
const SHEET_NAME = 'Main'; // Name of the sheet with user data
// Connect to the MySQL database
const dbUrl = 'jdbc:mysql://MyInfo';
const dbUser = 'MyInfo';
const dbPassword = 'MyInfo';
try {
const conn = Jdbc.getConnection(dbUrl, dbUser, dbPassword);
// Fetch user data from the specified row in Google Sheets
const sheet = SpreadsheetApp.openById(SHEET_ID).getSheetByName(SHEET_NAME);
const data = sheet.getRange(row, 1, 1, sheet.getLastColumn()).getValues()[0];
// Log fetched data
Logger.log('Fetched data: ' + data);
// Get headers (assuming first row is header)
const headers = sheet.getRange(1, 1, 1, sheet.getLastColumn()).getValues()[0];
const statusIndex = headers.indexOf('Status');
const roadnameIndex = headers.indexOf('Roadname');
const emailIndex = headers.indexOf('Email Address');
const phoneIndex = headers.indexOf('Phone Number');
const firstnameIndex = headers.indexOf('First Name');
const surnameIndex = headers.indexOf('Surname');
const positionIndex = headers.indexOf('Position');
const liasonIndex = headers.indexOf('Liason');
const clanNameIndex = headers.indexOf('Chapter Name');
const stateIndex = headers.indexOf('State');
const status = data[statusIndex];
const roadname = data[roadnameIndex];
const email = data[emailIndex];
const phone = data[phoneIndex];
const firstname = data[firstnameIndex];
const surname = data[surnameIndex];
const position = data[positionIndex];
const liason = data[liasonIndex];
const clanName = data[clanNameIndex];
const state = data[stateIndex];
Logger.log('Updating database with: ' + JSON.stringify({
roadname, state, status, position, liason, clanName, firstname, surname, phone, email
}));
if (status.toLowerCase() === 'active') {
insertOrUpdateActiveUser(conn, roadname, state, status, position, liason, clanName, firstname, surname, phone, email);
} else {
updateInactiveUser(conn, email);
}
// Close the database connection
conn.close();
} catch (error) {
Logger.log('Error updating database row: ' + error);
}
}
This is what i have in my settings.
Project OAuth Scopes
5 Scopes Requested
See all your Google Sheets spreadsheets https://www.googleapis.com/auth/spreadsheets.readonly
See your primary Google Account email address https://www.googleapis.com/auth/userinfo.email
Connect to an external service https://www.googleapis.com/auth/script.external_request
See, edit, create, and delete all of your Google Drive files https://www.googleapis.com/auth/drive
See and download all your Google Drive files https://www.googleapis.com/auth/drive.readonly