Google Drive API Insufficient Permission: Request had insufficient authentication scopes

Viewed 10771

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 Answers

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']

Related