【问题标题】:Updating and Resolving Comments in Google Sheet更新和解决 Google 表格中的评论
【发布时间】:2021-01-12 03:58:38
【问题描述】:

我想使用服务帐户更新/解决谷歌电子表格上的 cmets。目前关注GDrive V3 API guide; 页面上的 API 资源管理器运行良好,但我无法在 Python 上复制它。

GET 和 LIST 方法工作正常,但 PATCH 不断返回旧内容并且不会更新。

这是我的代码:

from googleapiclient.discovery import build
from google.oauth2 import service_account

credentials_file = './.config/gspread/service_account.json'
scope = ['https://spreadsheets.google.com/feeds', 'https://www.googleapis.com/auth/drive', 'https://www.googleapis.com/auth/drive.file','https://www.googleapis.com/auth/drive.appdata']
credentials = service_account.Credentials.from_service_account_file(credentials_file, scopes=scope)
service = build('drive', 'v3', credentials = credentials)
service.comments().update(commentId=<<commentId>>, fileId=<<fileId>>, fields='content', body={'content': 'new comment', 'resolved': True}).execute()

>>> returns {'content': 'old comment'}

知道有什么问题吗?感谢您的帮助!

【问题讨论】:

  • 嗨!我能够使用我的帐户正确运行它。当您不使用服务帐户时它是否有效?另外,您是否将domain wide delegation 授予您的服务帐户?
  • 您好,感谢您的建议!当我使用 OAuth 2.0 客户端凭据时它可以工作(:

标签: python-3.x google-sheets google-drive-api service-accounts


【解决方案1】:

正如Mateo 所建议的,在使用 OAuth 2.0 客户端凭据(密钥文件)时修补 cmets 有效

【讨论】:

    猜你喜欢
    • 2018-08-21
    • 1970-01-01
    • 2018-11-06
    • 1970-01-01
    • 2014-07-01
    • 1970-01-01
    • 2010-11-14
    • 1970-01-01
    • 2020-05-03
    相关资源
    最近更新 更多