0
votes

I have two environment for single google-app-script project. One with Sandbox and one with Production. Both have same code because, I copied Sandbox code into Production environment project.

Both are reading and writing same spreadsheet file with id 13vlLM5Tc7z4m-XXXXX-Kdjg. Below is the sample code.

While I run my 'google-app-script' project as web application, update work fine with Sandbox env but it gives below error for production env.

You do not have permission to access the requested document.

I check everything. I have full access of both 'google-app-script' project as well spreadsheet.

This is the code I used to find and update spreadsheet data.

var wb = '13vlLM5Tc7z4m-XXXXX-Kdjg';
var sheet = SpreadsheetApp.openById(wb);
var sheetData = sheet.getDataRange().getValues();
sheetData.shift();
var key = 'XYZ';
for(var i=0; i<sheetData.length; i++){
    if(key!=undefined && key!='' && key == sheetData[i][21]){
        resetPassUser = techSheetData[i];
        var values = [['Yes']];
        var nextRow = index+2; // get next row     
        sheet.getRange(nextRow, 23, 1, 1).setValues(values);
        break;
    }
}

It should update spreadsheet data using production env project also. Because code and permission are same. But instead it is giving me error.

You do not have permission to access the requested document.

1
The pictured error seems to be with your doGet(), not the code you posted. Have you verified your web app publication settings and that the account you're using to access has permissions? - Diego
Please show the Execution transcript so we can see exactly when the error actually occurs. - Tedinoz

1 Answers

1
votes

I think your authorization is confused. Try adding this to your app code

 /**
   * @NotOnlyCurrentDoc
   */