I created a custom script to be run from google sheets which I need to create a file. The script uses the following code excerpt:
/*
Custom function to call IEXAPI IEXkeystatearningsdate
@customfunction
*/
function IEXkeystatearningsdate(inputsymbol, stat, version) {
if (version == "Sandbox" || version == "sandbox")
var url="https://sandbox.iexapis.com/stable/stock/"+inputsymbol+"/stats/"+stat+"?token=xyz";
else
var url="https://cloud.iexapis.com/stable/stock/"+inputsymbol+"/stats/"+stat+"?token=xyz";
var response=UrlFetchApp.fetch(url); //Call REST API
var json=response.getContentText();
var data = JSON.parse(json); //Parse into JSON object
var d = new Date();
var n = d.toLocaleString();
var fn = "IEXkeystatearningsdate_" + n;
DriveApp.createFile(fn,inputsymbol, MimeType.CSV);
return (data);
}
However, I receive this message:
"Exception: You do not have permission to call DriveApp.createFile. Required permissions: https://www.googleapis.com/auth/drive (line 20)"
When I run this script directly from the script editor, I don't receive this message.
This is my manifest file:
{
"oauthScopes": [
"https://www.googleapis.com/auth/drive"
],
"timeZone": "America/Los_Angeles",
"dependencies": {
},
"exceptionLogging": "STACKDRIVER",
"runtimeVersion": "V8"
}
I do not use G-Suite. I only use google/sheets for my personal use. The OAuth FAQ says this call should be allowed for personal use. Can someone help me with what I need to do to get this to work?