pydrive

PyDrive: Invalid client secrets file

倾然丶 夕夏残阳落幕 提交于 2019-12-05 17:12:16
问题 I am trying to use PyDrive to get a list of all files in my Google Drive. I have read through the docs and completed all steps. I have client secrets.json saved down, but I continue to get the following error. The code I am using is: from pydrive.auth import GoogleAuth from pydrive.drive import GoogleDrive gauth = GoogleAuth() gauth.LocalWebserverAuth() # Creates local webserver and auto handles authentication drive = GoogleDrive(gauth) file_list = drive.ListFile({'q': "'root' in parents and

PyDrive guath.Refresh() and Refresh Token Issues

Deadly 提交于 2019-12-05 12:59:46
Like others, I'm trying to get the Google refresh token to work in order to run scheduled tasks that copy and rename files. When I first manually authenticate within a terminal, my url ends in &access_type=offline. However, when I go in and try to manually use gauth.Refresh() in ipython, it fails with the same error as when my credentials file expires: pydrive.auth.RefreshError: No refresh_token found.Please set access_type of OAuth to offline. How do I actually set access_type to offline? Any suggestions are greatly appreciated. I have been here , here , and here trying to troubleshoot this.

List of file in a folder/ DRIVE API PyDRIVE

一曲冷凌霜 提交于 2019-12-05 05:54:50
I can't change folder and view what's inside. drive = GoogleDrive(gauth) file_list = drive.ListFile({'q': "'root' in parents and trashed=false"}).GetList() for file1 in file_list: print("File %s\n\n",(file1)) I used the following code: file_list = drive.ListFile({'q': "'/test1' in parents and trashed=false"}).GetList() but it doesn't work. There's the documentation of the functions I used: https://developers.google.com/drive/v3/reference/files/list You have to insert the folder ID instead of its path. You can get the ID in different ways: Using PyDrive: If you list all folders in root, you can

python + google drive: upload xlsx, convert to google sheet, get sharable link

假如想象 提交于 2019-12-05 03:59:01
The flow of my desired program is: Upload an xlsx spreadsheet to drive (it was created using pandas to_excel ) Convert it to Google Sheets format Specify that it is editable by anyone with the link Get the link and share it with someone who will enter information Download the completed sheet I am currently using PyDrive, which solves steps 1 and 5, but there are a few unsolved problems. How can I convert to google sheets format? I tried to just specify the mimeType as 'application/vnd.google-apps.spreadsheet' when I created the file to upload with PyDrive, but that gave me an error. How can I

Create a folder (if not exists) on google drive and upload a file to it using Python script

只愿长相守 提交于 2019-12-04 21:36:40
问题 So far I can upload file to the folder if it exists. I can't figure out a way to create one though. So if the folder does not exist, my script dies. import sys from pydrive.auth import GoogleAuth from pydrive.drive import GoogleDrive gpath = '2015' fname = 'Open Drive Replacements 06_01_2015.xls' gauth = GoogleAuth() gauth.LocalWebserverAuth() drive = GoogleDrive(gauth) file_list = drive.ListFile({'q': "'root' in parents and trashed=false"}).GetList() for file1 in file_list: if file1['title']

User rate limit exceeded after a few requests

血红的双手。 提交于 2019-12-04 07:42:27
I am using Google Drive API through pydrive to move files between two google drive accounts. I have been testing with a folder with 16 files. My code always raises an error in the sixth file "User rate limit exceeded"> I know that there is a limit for the number of request (10/s or 1000/100s), but I have tried the exponential backoff suggested by the Google Drive API to handle this error. Even after 248s it still raises the same error. Here an example what I am doing def MoveToFolder(self,files,folder_id,drive): total_files = len(files) for cont in range(total_files): success = False n=0 while

Pydrive error: No downloadLink/exportLinks for mimetype found in metadata

前提是你 提交于 2019-12-03 22:19:47
问题 I am trying to download a simple text file from google drive automatically with the pydrive module for python. I keep getting the following error: Traceback (most recent call last): File "C:\GIS\AVGOPS\Scripts\GoogleDrive_Test.py", line 20, in item.GetContentFile(r'C:\Users\pfilyer\Desktop\googedrive\' + item['title']) File "C:\Python27\ArcGIS10.4\lib\site-packages\pydrive\files.py", line 210, in GetContentFile self.FetchContent(mimetype, remove_bom) File "C:\Python27\ArcGIS10.4\lib\site

“UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80” while loading pickle file using pydrive on google colaboratory

早过忘川 提交于 2019-12-02 14:05:10
问题 I am new to using google colaboratory (colab) and pydrive along with it. I am trying to load data in 'CAS_num_strings' which was written in a pickle file in a specific directory on my google drive using colab as: pickle.dump(CAS_num_strings,open('CAS_num_strings.p', 'wb')) dump_meta = {'title': 'CAS.pkl', 'parents': [{'id':'1UEqIADV_tHic1Le0zlT25iYB7T6dBpBj'}]} pkl_dump = drive.CreateFile(dump_meta) pkl_dump.SetContentFile('CAS_num_strings.p') pkl_dump.Upload() print(pkl_dump.get('id')) Where

“UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80” while loading pickle file using pydrive on google colaboratory

我的未来我决定 提交于 2019-12-02 07:08:56
I am new to using google colaboratory (colab) and pydrive along with it. I am trying to load data in 'CAS_num_strings' which was written in a pickle file in a specific directory on my google drive using colab as: pickle.dump(CAS_num_strings,open('CAS_num_strings.p', 'wb')) dump_meta = {'title': 'CAS.pkl', 'parents': [{'id':'1UEqIADV_tHic1Le0zlT25iYB7T6dBpBj'}]} pkl_dump = drive.CreateFile(dump_meta) pkl_dump.SetContentFile('CAS_num_strings.p') pkl_dump.Upload() print(pkl_dump.get('id')) Where 'id':'1UEqIADV_tHic1Le0zlT25iYB7T6dBpBj' makes sure that it has a specific parent folder with this

Pydrive google drive automate authentication

懵懂的女人 提交于 2019-11-30 13:39:29
I have the following piece of code: from pydrive.auth import GoogleAuth gauth = GoogleAuth() gauth.DEFAULT_SETTINGS = {'save_credentials': True,'client_config_backend': 'settings', 'oauth_scope': ['https://www.googleapis.com/auth/drive'], 'get_refresh_token': True, 'save_credentials_file':"credential_log.txt", 'save_credentials_backend': 'file'} gauth.client_config = {'client_id': '499039293801-krogpnentl6qk035vt4hcd36nefiautt.apps.googleusercontent.com', 'client_secret': 'iqFCuOh36amMFi3U1dkyCWJK', 'redirect_uri':'urn:ietf:wg:oauth:2.0:oob','revoke_uri': 'None', 'token_uri':'https://accounts