英文:
How do I access Google Drive Revisions API using a service account?
问题
当我想要获取文件更改时,我收到以下错误消息:
用户对文件 *** 没有足够的权限
我的代码:
SCOPES = ['https://www.googleapis.com/auth/drive']
credentials = service_account.Credentials.from_service_account_file(
'service.json', scopes=SCOPES)
service = build('drive', 'v3', credentials=credentials)
service.revisions().list(fileId=DOC_ID)
IAM:
附注:此文件是由我在docs.google.com中创建的。
英文:
When I want to get file changes, I get the following error:
The user does not have sufficient permissions for file ***
My code:
SCOPES = ['https://www.googleapis.com/auth/drive']
credentials = service_account.Credentials.from_service_account_file(
'service.json', scopes=SCOPES)
service = build('drive', 'v3', credentials=credentials)
service.revisions().list(fileId=DOC_ID)
IAM:
P.S.: This file was created by me in docs.google.com.
答案1
得分: 1
答案这个问题,因为它是在评论中添加的。错误信息"The user does not have sufficient permissions for file ***"通常指的是文件的权限问题。要解决这个问题,你应该与服务账号共享文件。这是基于Google文档中的说明这里。
英文:
Answering the question, since it was added in the comment. The error message "The user does not have sufficient permissions for file ***" usually refers to a problem with the permissions in the file. To solved the issue you should share the file with the services account. This is base in the Google Documentation here
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论