Google Drive API Insufficient Permission: Request had insufficient authentication scopes

Deadly 提交于 2021-02-10 17:53:51

问题


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


回答1:


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




回答2:


You need to change the scopes to one of the following

  • https://www.googleapis.com/auth/spreadsheets
  • https://www.googleapis.com/auth/drive

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



来源:https://stackoverflow.com/questions/64508018/google-drive-api-insufficient-permission-request-had-insufficient-authenticatio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!