I'm attempting to access data from one Google Sheets spreadsheet in order to update entries in another Google Sheets spreadsheet.
The code I've written to accomplish this so far is as follows:
var ss1 = SpreadsheetApp.openById("123456789").getSheetByName('Sheet1');
function onEdit (e) {
var sheet = e.source.getActiveSheet();
sheet.getRange("C4").setValue(ss1.getUrl());
}
But I'm getting the following error when I edit an entry in the target spreadsheet to trigger the script:
Exception: You do not have permission to call SpreadsheetApp.openById. Required permissions: https://www.googleapis.com/auth/spreadsheets at unknown function
How do I obtain permissions to run the openByID() method or is there a better way to access an external Google Sheets spreadsheet's data?