Open billchenJT opened 4 years ago
Hello billchenJT,
I had the same problem which was a bit annoying. It turns out it is a small modification to PyDrive lib itself. I just figured it out from another post and it works (thanks to SMB784):
https://github.com/gsuitedevs/PyDrive/issues/160#issuecomment-499920540
Once you have brought the modification to files.py in PyDrive, you can use the following code to download any file from the Team Drive (it worked for me):
from pydrive.auth import GoogleAuth from pydrive.drive import GoogleDrive
gauth = GoogleAuth() gauth.LoadClientConfigFile('client_secrets.json') drive = GoogleDrive(gauth)
team_drive_id = 'XXXXXXXXX' parent_folder_id = 'XXXXXXXXX' file_id = 'XXXXXXXXX'
f = drive.CreateFile({ 'id': file_id, 'parents': [{ 'kind': 'drive#fileLink', 'teamDriveId': team_drive_id, 'id': parent_folder_id }] })
f.GetContentFile('
I hope it helps :) Kind regards, Berti
@Berti30 there is an actively maintained version PyDrive2 (Travis tests, regular releases including conda) from the DVC.org team. I think is solves this and some other problems - please give it a try and let us know - https://github.com/iterative/PyDrive2
I have a similar problem with a 404 file not found message but using InsertPermission() with a file on a shared drive (it works fine on my drive).
PyDrive2 doesn't appear to change this and I am struggling to see what the issue might be (I have confirmed the file ID is correct as well).
Do additional 'supportsTeamDrives' entries need to be added to the permission functions as well?
It appears as though that is the issue, I added the supportsTeamDrives parameter to InsertPermission() at line 325 of files.py and it has inserted the permission:
permission = self.auth.service.permissions().insert( fileId=file_id, body=new_permission, supportsTeamDrives=True).execute(http=self.http)
@cartochris would be great if you could create a PR to the actively maintained version - iterative/PyDrive2
... we already fixed most of these issues with supportAllDrives
(I think supportsTeamDrives
was deprecated in favor of supportAllDrives
)
Sure just added a PR.
I am using python to fetch files from the google shared drive, which is owned by the team. The currently issue is I can parse all the file ID's but I cannot using the pyDrive to download or read the content of the file.
First I generated a "drive":
Then I use the file id to get the content:
The error I got is:
However, the file does exist when I go to the
https://www.googleapis.com/drive/v2/files/xxx?alt=json
, it return:I have no idea what is going on. Please help! Thanks,