2
votes

I successfully completed the quickstart shows HERE:

https://developers.google.com/drive/api/v3/quickstart/python

I wish to go further and begin to upload files and folders. To do so I have replaced the scope with: SCOPES = ['https://www.googleapis.com/auth/drive']

I have also replaced the execution with

national_parks = ['Yellowstone', 'Rocky Mountain', 'Yosemite']

for national_park in national_parks:
    file_metadata = {'name': national_park,
                     'mimeType': 'application/vnd.google-apps.folder'
                     # 'parents': []

                     }
    service.files().create(body=file_metadata).execute()

I then get an error: googleapiclient.errors.HttpError: <HttpError 403 when requesting https://www.googleapis.com/drive/v3/files?alt=json returned "Insufficient Permission: Request had insufficient authentication scopes.">

Help please

2
When changing the scopes, have you deleted the token.pickle file?Kessy

2 Answers

2
votes

Looks like your scopes might not be correct, replace with the following:

SCOPES = ['https://www.googleapis.com/auth/spreadsheets', 'https://www.googleapis.com/auth/drive']

1
votes

You need to change the scopes to one of the following

and delete the token.pickle file, it will then prompt you to authorize the application again this time with the required scope of permissions needed to call that method