Sorry for my english. I try copy files to another folder. But i have error:
googleapiclient.errors.HttpError: https://www.googleapis.com/drive/v2/files/1yH7LZ54uaiOl4T0J5UoJ9zb30cVKtW19/copy?alt=json returned "This file cannot be copied by the authenticated user.">
my code:
parent_folder = 'sdadasdasdasdasd23123123123-9'
drive = DriveBox()
list_files = drive.list_files_from_parent_folder(parent_folder)
new_folder = drive.create_folder("228", parent_folder)
for file in list_files:
drive.g_drive.auth.service.files().copy(fileId=file['id'],
body={"parents": [{"kind": "drive#fileLink",
"id": new_folder['id']}], 'title': file['title']})\
.execute()
class DriveBox:
class DriveBox:
g_drive = None
instance = None
def __new__(cls, *args, **kwargs):
if cls.instance is None:
gauth = GoogleAuth()
try:
gauth.CommandLineAuth()
except (AuthenticationError, RefreshError) as e:
print(e)
cls.g_drive = GoogleDrive(gauth)
cls.instance = super(DriveBox, cls).__new__(cls)
return cls.instance
my settings.yaml
client_config_backend: settings
client_config:
client_id: 1111111111111111
client_secret: 1111111111111111
save_credentials: True
save_credentials_backend: file
save_credentials_file: credentials.json
get_refresh_token: True
oauth_scope:
- https://www.googleapis.com/auth/drive
- https://www.googleapis.com/auth/drive.file
- https://www.googleapis.com/auth/drive.install
- https://www.googleapis.com/auth/drive.appfolder
- https://www.googleapis.com/auth/drive.metadata