Monitor Google Drive new files and make sure they are private
Go through the quickstart guide and make sure you complete all the Set Up Python Quickstart guide)
pip install the next packages:
pip install --upgrade google-api-python-client google-auth-httplib2 google-auth-oauthlib python-dateutil
- Permissions required as described in the Python Quickstart guide. make sure you have access to the account you are going to use
- Scopes for which we request an access token are written in the global variable SCOPES inside
- Tokens: The code generates an Access Token with the scopes described above and keeps it in the file
token.json
- Download the repo to a working directory
- In the same directory add your
credentials.json
file from the Drive API - From the same working directory execute:
python main.py
- In the first execution or after a while not using the code, your browser will open and you'll have to enter valid credentials as provided to the testing account in the Google Drive API
- A new file will be created
token.json
which will contain your access token to the requested scopes - If you want, you should use a
crontab
(Linux) orservice
(Windows) for a scheduled execution of this code
- The code makes use of two other files:
files_changed_by_program.json
- Which keeps the Ids of the files that the program changed their permissionslast_check_time.txt
- Which keeps the last execution time to know which files are new- We treat files in the Trash same as normal files. This can be changed if needed (it's in the ToDo section)
- A schedule execution will still require once in a while to reauth your account manually every time the access token is not valid anymore
- for any unknown exception try to delete the
token.json
and run again - After a file is being changed to private, its considered as a new file for the next run because the modification time is greater then last check time. But nothing will happen in the next run because its already private
- There is a
changes.list
api but I thought that for our purpose it's better to implement by time diffs because it's more simple for the specific mission
ideas the not tested or checked, just general ideas
- drives.hide - lets you hide a drive from the default view, maybe we can copy private files to this drive with different permissions for the files while stay unnoticible
- file revisions - maybe there is a way to hide malicious content in a file revision
- replies / comments - maybe there is an XSS exploit in the content field (it uses html to show the content)
- add an option to ignore files in the Trash
- more precise Exceptions handling