I'd like to pull data into a Google doc from a MySQL database (quote / invoice data) via a Google Apps Script. The doc will be used by several people (in a small agency). However these project managers should not be able to see the login details that are embedded in the Apps Script Code. I don't care if they see the Code. So is there a trick to hide or lock the login details for the database? Any advice??
Google apps script has a concept called properties services . You can use the Script properties or the user properties to stored your credentials:
Script properties are shared among all users of a script, add-on, or web app. They are typically used for app-wide configuration data, like the username and password for the developer's external database.
Usage:
var scriptProperties = PropertiesService.getScriptProperties();
//setting
scriptProperties.setProperty('SERVER_URL', 'http://www.example.com/');
//retrieving
var units = userProperties.getProperty('DISPLAY_UNITS');
User properties are shared among the current user of a script, add-on, or web app and typically used for User-specific settings, like metric or imperial units.
Usage:
var userProperties = PropertiesService.getUserProperties();
//setting
userProperties.setProperty('DISPLAY_UNITS', 'metric');
//retrieving
var units = userProperties.getProperty('DISPLAY_UNITS');
You can also manually set, view or remove these properties by going to File->Properties
and the relevant tab.
There is also the third kind of property called document properties about which you can find out here .
As some of you mentioned, the problem is that a user could read out the login details stored externally with an appropriate script. So my solution for now is to run the SQL select in a standalone script embedded as web app and to let the standalone script write the query result into a spreadsheet. The editable doc will then Import the data from there.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.