Password Protection for Exported Data from Google Sheet - google-apps-script

I saved my data Google Sheet, I can limit access to this data with Sharing feature available at all Google Docs (Sheet). Is there any solution for me to protect exported document from Google Docs (and Sheet)?.
What I can think of right now, password protection on file level as we can found at Microsoft Excel file. I am okay if I need to do some coding in Google Script found at GSuite.

Answer:
Unfortunately there is no way of programmatically setting a password of an exported Drive File.
More Information:
The only programmatic export method of the G Suite APIs is the Files: export method of the Drive API. This end point does not have a way of setting a password to protect the exported file.
Exported files also can not be of a Google Drive File MIME Type and so you can not set a password like one would be able to using the Protect File menu item for web-app deployed Sheet.
This is therefore, sadly, impossible to do. The password protection would have to be set manually on the host machine after export.
References:
Google Drive API Files: export method
Google Drive File MIME Types

Related

View and audit all App Scripts on GSuite domain

Is there a way for me to be able to view and audit all app scripts created in my gsuite domain being an admin, without it being shared with me? I know that I'm able to pull all files in drive using vault and I assume if the app script files were still in drive, I could probably have searched for them that way, but that doesn't work anymore.
Yes, you can use Vault to search for the Scripts projects. The GAS files will display this icon next to the script title https://ssl.gstatic.com/docs/doclist/images/mediatype/icon_1_script_x16.png
You can use Vault to download it but it will be a json file, you can't preview the GAS JSON file but you can use the Drive API to import it to your own account, more info at Import Google app script project from JSON file

is it possible to download GMail attachment to local folder?

i want to download attachment from gmail and save it to local folder using google script. i did some research about this and i could't find any solution.
so far, i managed to save gmail's attachment to google drive only.
var attachmentBlob = attachment[0].copyBlob();
var file = DriveApp.createFile(attachmentBlob);
folder.addFile(file);
or, is it possible to create a google script to auto download file from google drive?
need some advice.
As #Sujay already mentioned you cannot download a file to a local folder using Google AppScript because GAS runs server-side.
You have already taken a good step with the code to save the attachment as a file to your Google drive.
To answer your sub-question 'is it possible to create a google script to auto download file from google drive?', you do not need a script to do that, that is what the Google Drive Desktop App (https://www.google.com.ng/drive/download/) does exactly.
It syncs all the files you add to your drive to your local-pc. You can also edit Google Drive preferences to sync select folders only, in your case that might be the drive folder referenced in your folder variable.
GAS runs on the server side, and only has access to Google's internal architecture. To save locally it'll need to create some kind of a blob and trigger a download within your browser. not sure if you can do that.

Google apps script save google spreadsheet to excel version and load it from add-on

Hi I have an idea about file management between GAS and my BDserver. How so? Well, I'd like to have predesigned spreadsheet and save them somehow in my bd. Then users've installed my add-on can load that predesigned spreadsheet on his/her current spreadsheet. PD: Besides the user could save custom "predesigned spreadsheets" for helping to grow the app. How can I save a spreadsheet (Google Drive Spreadsheet) in my server and later call that "file" and load it in a empty spreadsheet? xml? json? export like excel file .xls??. I appreciate your suggestions.
You may find helpful information in Google Apps Script regarding the things that you can do with Google Apps like Docs, Sheets and Forms. You can also find links from the documentation which could help if you've developed a script for Google Sheets and want to share it with the world. App Script lets you publish your script as an add-on so others can install it from the add-on store.
In addition to that, to save your spreadsheet in your own database, you need to connect to it through Apps Script's JDBC service. First, you need to ensure that your database accepts connections from any of Apps Script's IP addresses as detailed in JDBC - Setup for other databases.

How to create Google Sheets file when CSV file is downloaded

When a user downloads a CSV file from an arbitrary site, I would like to be informed of this event and automatically upload the same file as a Google Sheets file. Is this possible or would this be violating a fundamental browser security concept?
The CSV file in question does not have a URL, but is created on the fly by the arbitrary web site, when the user clicks a button. An example would be the user's list of financial transactions at a bank web site.
I am not new to Google Apps/Drive but I am new to Google Apps Script.
There is no way to detect that kind of events.
I can't even imagine a function that would allow for automatic file upload of a local file... don't forget Google Apps Script is a server based environment.

Granting APP authorization to Google Drive files

I am trying to authorize files on my google drive with specific APP authorization I created. As files on my google drive can only be manipulated by its authorized app, is there any way I can convert these "None" authorized file with APP authorization? And, if yes, by which function?
I looked all over the tutorial document but only find discussion about permission. The only method I can think about is uploading these files to google drive with upload function from my created app. But I guess there is a much smarter way. Do any one has the same experience?
Here list my steps to create authorized file:
First, I start my app from using sample code, DrEdit. https://developers.google.com/drive/examples/python;
From the code, I successfully open new files and saw them listed on my google drive.
From view authorized app, I can clear see these apps created from my app have their authorization signed with app ID. The other files original belong to me have these authorization signed as "None".
I had the same issue and had to change the scope from https://www.googleapis.com/auth/drive.file to https://www.googleapis.com/auth/drive which gives full access to all drive files rather than just the ones created by the app.