gpt4 book ai didi

python - 使用 Google Sheets API 公开电子表格?

转载 作者:行者123 更新时间:2023-11-28 17:13:36 26 4
gpt4 key购买 nike

我想使用 Google Sheets API 以编程方式创建 Google 表格,将其公开,然后将其嵌入到网页上的 IFRAME 中。

我不知道如何使用 API 使电子表格对公众可见。创建或更新电子表格时,API 中是否有针对此的设置?

我关注了Google's Python Quickstart并能够创建和更新电子表格。

更新:

我可以使用 Drive API 公开电子表格,并且可以从其他帐户访问它。但是,这不允许您将它嵌入到网页中(它仍然在框架中声明“我们很抱歉。该文档未发布。”)。为此必须有另一个设置。 是否可以使用 Drive API 进行设置?

FWIW 这是我能够公开它的方法(但仍然无法将工作表嵌入到 iframe 中)

SCOPES = ['https://www.googleapis.com/auth/spreadsheets',
'https://www.googleapis.com/auth/drive.metadata',
'https://www.googleapis.com/auth/drive.file',
'https://www.googleapis.com/auth/drive']

drive_client = discovery.build('drive', 'v3', http=creds.authorize(Http()))
user_permission = {
'type': 'anyone',
'role': 'reader',
}
result =drive_client.permissions().create(
fileId=sheed_id,
body=user_permission,
).execute()

最佳答案

权限是 Google 云端硬盘的一部分,并不特定于电子表格,因此您需要使用 Google Drive API为了那个原因。查看reference .

关于python - 使用 Google Sheets API 公开电子表格?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45669360/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com