A script to remove a specified user/email from all shared files and folders in Google Drive in bulk.
StopSharingMyGoogleDrive is a Python script that automates the process of removing a specific user's access from all files and folders shared with them in your Google Drive. This can be particularly useful for managing permissions and ensuring that only authorized users have access to your documents specially if you have a large number of files shared.
- Automated Access Removal: Remove a specified user from all files they have access to in your Google Drive.
- Batch Processing: Efficiently handles large numbers of files.
- Simple Configuration: Easily set up and configure the script with your Google API credentials.
- Python 3.6 or higher
- Google API credentials (OAuth 2.0 Client ID)
- Google Drive API enabled
-
Clone the repository:
git clone https://github.com/junaidtitan/StopSharingMyGoogleDrive.git cd StopSharingMyGoogleDrive -
Create a virtual environment (optional but recommended):
python3 -m venv venv source venv/bin/activate -
Install the required packages:
pip install --upgrade pip pip install --upgrade google-api-python-client google-auth-httplib2 google-auth-oauthlib
-
Set up Google API credentials:
- Go to the Google Cloud Console.
- Create a new project or select an existing one.
- Enable the Google Drive API for your project.
- Create OAuth 2.0 credentials and download the
credentials.jsonfile. - Place the
credentials.jsonfile in the root directory of this project.
- Go to the Google Cloud Console.
- Navigate to "APIs & Services" > "OAuth consent screen".
- Scroll down to the "Test users" section.
- Add the email addresses of the users who need to access the application (including your own).
- Save the changes.
-
Run the script:
python3 stop.py
-
Follow the authentication prompts to authorize the script to access your Google Drive.
-
Enter the email address of the user you want to remove when prompted.
Here is an example of how to use the script:
$ python3 stop.py
Enter the email of the user to remove: [email protected]
Removing [email protected] from file1
Removing [email protected] from file2
...If you encounter any issues or have questions, please open an issue on GitHub. Here are some common troubleshooting tips:
-
Ensure that you are using the correct Python environment. Use
python3andpip3to ensure compatibility. -
If you encounter issues with package installation, make sure to upgrade
pip:pip install --upgrade pip
-
Verify the installed packages:
pip3 list | grep google
-
ModuleNotFoundError: No module named 'google': Ensure you have installed the required packages with:
pip3 install --upgrade google-api-python-client google-auth-httplib2 google-auth-oauthlib
Contributions are welcome! Please open an issue or submit a pull request with any improvements or bug fixes.
This project is licensed under the MIT License - see the LICENSE file for details.