Who can access your Google Drive files? Find out with this simple script
Over the years, most people have been using cloud storage services to store and share files with others because of their convenience. But imagine this: you’ve been using Google Drive to share personal, school, and maybe even work-related photos, documents, spreadsheets, etc. with other people for years now. Say you developed a business plan along with other strategy documents for a new startup idea that you came up with and shared them through a link with some people you met at a networking event. Things got in the way, so you had to put a pin in that idea. Years passed and now you want to resume working on the business strategy for that old idea you never got the chance to work on; the problem is, now you have so many files in your Drive that you lost track of who even has access to most of your files. How comfortable would you be starting a business knowing that random people have had access to and shared it with others or worse, might have stolen it already?

How to know if you need to take action on file permissions and sharing settings in Google Drive
You've probably been wondering how and if you can have an overview of who has access to which file from your Google Drive. The answer is yes, and in this post, we’ll show you how with Google Apps Script.
Google Apps Script is a flexible, JavaScript-based scripting language built into Google Workspace apps (Docs, Sheets, Slides, Forms, etc.) that lets you create add-ons and automate tasks in those Workspace apps. It runs on Google’s servers, so you don’t need to install anything and you can just code in any browser.
We will be using a script made by Amit Agarwal who is a Google Developer Expert for Google Workspace and Google Apps Script; the script uses the DriveApp service to fetch all the files from your Google Drive and sends an email report with the sharing access and permissions to the Google account that authorized the action.
Disclaimer: Please note that the script requires access to your Google Account. You are free to decide if you want to try running the script to see your personal sharings; however, when it comes to work-related accounts, we recommend consulting with your IT department or security team beforehand.
Setting it up - how to build the script
Step 1. Sign in to the Google Account you want to check the file permissions
Step 2. Go to script.google.com to open the script editor

Step 3. Click on “New Project”

Step 4. Delete any code left in the script editor

Step 5. Go to https://www.labnol.org/code/19538-file-sharing-permissions and copy the code from there

Step 6. Return to the script editor and paste the code into the script editor

Step 7. At the top left, click “Save”

Step 8. At the top left, click “Untitled project”

Step 9. Type in “File permissions and sharing settings“ and click “Rename”

Trying it out - how to run the script
Step 10. At the top left, click “Run”

Step 11. Click on “Review permissions” and then click “Allow”

Step 12. After the script finishes running, go to your Gmail inbox and take a look at the file-sharing report that you just received

Note: Running this script has some limitations meaning that if you have many files or sharings, the script is limited in the execution time and size of the report, so in general it is not very useful in larger organizations.
