Package: pydriveziead
DeprecatedThis project is deprecated and no longer maintained. No further changes will be made.In one of the PyDriveissues, we learned about thePyDrive2fork of PyDrive. Forks are permitted under PyDrive’slicense, and we hope that such forks will be useful for the needs of PyDrive users. The PyDrive team makes no endorsement or support promises of any particular fork, but we’re excited to see the open source license being a vehicle for new project development.PyDrivePyDriveis a wrapper library ofgoogle-api-python-clientthat simplifies many common Google Drive API tasks.Project InfoHomepage:https://pypi.python.org/pypi/PyDriveDocumentation:Official documentation on GitHub pagesGitHub:https://github.com/googleworkspace/PyDriveFeatures of PyDriveSimplifies OAuth2.0 into just few lines with flexible settings.WrapsGoogle Drive APIinto
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.How to installYou can install PyDrive with regularpipcommand.$ pip install PyDriveTo install the current development version from GitHub, use:$  pip install git+https://github.com/googleworkspace/PyDrive.git#egg=PyDriveOAuth made easyDownloadclient_secrets.jsonfrom Google API Console and OAuth2.0 is
done in two lines. You can customize behavior of OAuth2 in one settings
filesettings.yaml.frompydrive.authimportGoogleAuthfrompydrive.driveimportGoogleDrivegauth=GoogleAuth()gauth.LocalWebserverAuth()drive=GoogleDrive(gauth)File management made easyUpload/update the file with one method. PyDrive will do it in the most
efficient way.file1=drive.CreateFile({'title':'Hello.txt'})file1.SetContentString('Hello')file1.Upload()# Files.insert()file1['title']='HelloWorld.txt'# Change title of the filefile1.Upload()# Files.patch()content=file1.GetContentString()# 'Hello'file1.SetContentString(content+' World!')# 'Hello World!'file1.Upload()# Files.update()file2=drive.CreateFile()file2.SetContentFile('hello.png')file2.Upload()print('Created file%swith mimeType%s'%(file2['title'],file2['mimeType']))# Created file hello.png with mimeType image/pngfile3=drive.CreateFile({'id':file2['id']})print('Downloading file%sfrom Google Drive'%file3['title'])# 'hello.png'file3.GetContentFile('world.png')# Save Drive file as a local file# or download Google Docs files in an export format provided.# downloading a docs document as an html file:docsfile.GetContentFile('test.html',mimetype='text/html')File listing pagination made easyPyDrivehandles file listing pagination for you.# Auto-iterate through all files that matches this queryfile_list=drive.ListFile({'q':"'root' in parents"}).GetList()forfile1infile_list:print('title:{}, id:{}'.format(file1['title'],file1['id']))# Paginate file lists by specifying number of max resultsforfile_listindrive.ListFile({'maxResults':10}):print('Received{}files from Files.list()'.format(len(file_list)))# <= 10forfile1infile_list:print('title:{}, id:{}'.format(file1['title'],file1['id']))Concurrent access made easyAll calls made are thread-safe. The underlying implementation in the
google-api-client libraryis not thread-safe,
which means that every request has to re-authenticate an http object. You
can avoid this overhead by
creating your own http object for each thread and re-use it for every call.This can be done as follows:# Create httplib.Http() object.http=drive.auth.Get_Http_Object()# Create file object to upload.file_obj=drive.CreateFile()file_obj['title']="file name"# Upload the file and pass the http object into the call to Upload.file_obj.Upload(param={"http":http})You can specify the http-object in every access method which takes aparamparameter.Note: This is  not an official Google product.