PyGoogleDrive is a wrapper library of google-api-python-client that simplifies many common Google Drive API tasks You can just need to create credentials.json and place in your root directory.
- Homepage: https://pypi.python.org/pypi/PyGoogleDrive
- GitHub: https://github.com/fahadkhan09/pygoogledrive
- ReadTheDocs: https://pygoogledrive.readthedocs.io/en/latest/
- You can just need to create credentials.json and place in your root directory
- Simplifies OAuth2.0 into just few lines with flexible settings.
- Wraps Google Drive API into classes of each resource to make your program more object-oriented.
- Helps common operations else than API calls, such as content fetching and pagination control.
You can install PyGoogleDrive with regular pip command.
pip install PyGoogleDrive
- For credentials.json just visit https://console.developers.google.com/
- Create project
- Select credentials
- Add OAuth 2.0 Client IDs by clicking CREATE CREDENTIALS button
- select web application
- For Authorized JavaScript origins add http://localhost without '/' in end
- For Authorized redirect URIs add http://localhost/
- Download file and rename it to credentials.json
- Add this file to project directory
When you create instance it will automatically open url for google authentication After successfully authentication token.pickle file is created in root directory
from PyGoogleDrive.PyGoogleDrive import PyGoogleDrive
drive = PyGoogleDrive()We can use `drive` instance to create Folder
drive.createfolder('folder_name')createfolder function will return folder id that is created on Google drive
PyGoogleDrive handles custom file upload.
drive.uploadfile(name, file_path, mimetype, folder_name)uploadfile function will return file id created on google drive folder_name is optionals if you want to upload file in specific folder then add folder_name = 'document'