In Google Sheets, there is a script that uses "UrlFetchApp" to obtain information from an external API that requires an API key to be included in each call.
The sheet has a number of editors but only the owner should be able to see the API key, so storing the key in the script itself or using the PropertiesService is not an option.
Would the following solution keep sheet editors from seeing the key?
Create a new stand-alone Apps Script project.
In the stand-alone script, create the following function:
function fetchData(idFromSheetScript) { var secret = '/abc123'; var id = idFromSheetScript; var uri = 'https://.../'; var url = uri+id+secret; var data = UrlFetchApp.fetch(url); return data; }
Deploy the stand-alone script as a Library. Do not share the project with anyone.
In the Google Sheets-bound script, import the Library and use fetchData() function from the Library.
var response = fetchData('10');
Would the editors of the sheet where the Library is imported be able to see or obtain (through logging or otherwise) the "secret" variable in the Library or would they only be able to see the function's returned variable?