Package: drive-in
Drive-inMinimalistic Google Drive Library for Python.Table of ContentsFeaturesInstallationUsageLicenseFeaturesAuthentication: Easily authenticate with Google Drive using OAuth 2.0, and store the access token for future use.
Drive-In provides a CLI authentication process, guiding you through token creation.File Upload: Seamlessly upload files to your Google Drive, with support for multi-part uploads. You can specify
the file's name and the destination folder.File Download: Download files from Google Drive, also with multipart support. *API Interaction: Interact with the Google Drive API through a simplified interface, making it effortless to
perform operations like creating, updating, and deleting files or folders. *Error Handling: Drive-In includes error handling to help you handle unexpected situations, such as failed API
requests.* Due to Authentication Limitations, you can only view and edit files that were created using this tool.Installationpip install drive-inUsageFirst, import the library and create an instance of theDriveclass:fromdrive_inimportDrivedrive=Drive()This will prompt the user for authentication.Checking Authentication Status# Check if the authentication token is validifdrive.ping():print("Authentication is successful and server responds well.")else:print("Authentication failed.")Uploading a File# Upload a file to Google Drivefile_path="example.txt"drive.upload(file_path)Downloading a File# Download a file from Google Drivefile_id="your_file_id_here"downloaded_file=drive.download(file_id)# if no output target is passed, it is saved to the same name as it has on drive.# A reference to the file handle is returned.Accessing other Drive API EndpointsOther thanuploadanddownload, you can access REST resources with the HTTP verbs (GET, POST, PATCH, DELETE):drive.get("files")# perform GET /drive/v3/files# returns a Result object which has .success (bool) and .data (dict) properties.# _response and _url internal properties are available if you need access to this raw info.drive.post("files/123/comments",data=dict(content="..."))# perform POST to create a new comment.drive.delete("files/123")# perform DELETE /drive/v3/files/123resource=drive.resource("files")/123# dynamically build up the resource stringdrive.delete(resource)# also performs DELETE /drive/v3/files/123Seethe Google Drive API pagefor information about
available resources.AuthenticationThis library works only a public OAuth Client ID.
Since it is open source, a secret config or key can not be shared.
This leads to some limitations with how much the app can access.
Unfortunately, you can only access files created by this app (i.e. uploaded by it).OAuth CallbackSince oauth requires a callback URL, you're redirected to "https://oauth.trialandsuccess.nl/callback" after logging in.
This page simply echoes the access token from the request parameters usingoauth-echoer.You can also provide you own Client ID and callback URL when initializing a Drive instance:custom_clientid="123-abc.apps.googleusercontent.com"custom_url="https://yoursite.com/callback"drive=Drive(client_id=custom_clientid,redirect_uri=custom_url,)Licensedrive-inis distributed under the terms of theMITlicense.Disclaimer: This library is not officially affiliated with Google Drive or Google LLC. It is an open-source project
created to simplify interactions with Google Drive's API.