Mike Poretti
Mike Poretti

Reputation: 21

Google Drive API Insufficient Permission: Request had insufficient authentication scopes

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

Upvotes: 2

Views: 23037

Answers (4)

钟圣维
钟圣维

Reputation: 1

list of scopes with one boxed in red

Upvotes: 0

EmPlusPlus
EmPlusPlus

Reputation: 181

Not only must change the scope to the appropriate scope URL but also delete 'token.json' file and then create new token. Basically by running the code it will automatically create new token with the correct scope

Upvotes: 1

Linda Lawton - DaImTo
Linda Lawton - DaImTo

Reputation: 116948

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

Upvotes: 3

Rob Sweny
Rob Sweny

Reputation: 51

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

Upvotes: 5

Related Questions