- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我们使用 developers.google.com 创建了 api 用户并将凭据下载为 json 文件。现在在我的 macbook 上,gspread 身份验证在使用 credentials.json 时工作正常。当将相同的配置移动到 aws 上的 linux 服务器时,它给出 403 权限不足的错误。
pip 和 python 版本相同。
异常
gspread.v4.exceptions.APIError: {
"error": {
"errors": [
{
"domain": "global",
"reason": "insufficientPermissions",
"message": "Insufficient Permission"
}
],
"code": 403,
"message": "Insufficient Permission"
}
}
基本代码
import gspread
from oauth2client.service_account import ServiceAccountCredentials
scope = ['https://spreadsheets.google.com/feeds']
creds = ServiceAccountCredentials.from_json_keyfile_name('credentials.json', scope)
client = gspread.authorize(creds)
sheet = client.open('MySheetName').sheet1
最佳答案
尝试将您的 scope
变量更改为以下内容:
scope = ['https://spreadsheets.google.com/feeds',
'https://www.googleapis.com/auth/drive']
确保在 API 控制台中启用了 Drive API。
gspread 已经升级,现在基于 API v4。它速度更快,但需要更新范围。
关于python - gspread 身份验证抛出权限不足,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49258566/
我正在尝试编写一个程序来获取我在谷歌电子表格中记录的统计数据,并将它们写入一个文本文件,以便在流中读取和显示。该程序在大多数情况下运行良好,但偶尔会因以下原因而崩溃。这看起来像是一个 oauth 问题
我在谷歌驱动器中有两个文件(两个谷歌表格),我需要以常规模式将数据和格式从一个文件移动到另一个文件。 如下图所示,我需要维护不同的文本格式(粗体、文本颜色等): 我的第一次尝试是:使用 IMPORTR
我想向单元格添加超链接。我正在使用以下代码: cell_values = [1,'=HYPERLINK("' + some_url + '","' + some_text + '")',3] for
我想向单元格添加超链接。我正在使用以下代码: cell_values = [1,'=HYPERLINK("' + some_url + '","' + some_text + '")',3] for
我有一个像这样的谷歌电子表格 A B C D 0 1 2 3 4 5 7 8 9 8 7 6 5 3
我正在尝试使用 GSpread 调整 google 工作表中的列宽,但是我在整个网络上找不到有关该主题的任何文档。我已经尝试过实际的项目文档本身,以及堆栈溢出。 我查看了文档和堆栈溢出,之前没有人问过
在我的应用程序中,我有一堆不在范围内的单元格。目前我正在一一更新,但是需要很多时间。我想通过一个电话来批量更新它们。 我查看了其他一些 SO 线程,例如 this ,但就我而言,单元格不在范围内。 为
我已经能够使用适当的凭据成功连接到 gspread,但是当我尝试打开一个现有文件(在我的谷歌帐户中)时,它失败了。我试过 open() 和 open_by_key()。我假设我的帐户与我刚刚创建的服务
我需要在文件系统上下载 Google 电子表格,我正在使用 Gspread 从 Google 云端硬盘读取文件,效果很好。 我尝试导出为 CSV,但这当然会丢弃格式。 json_key = j
我正在尝试使用 Gspread for Python 合并 Gsheets 中的单元格,但是我找不到任何文档。 我已经使用 gspread_formatting 模块来格式化单元格的文本和颜色,但我找
我正在尝试使用 gspread 库使用 python 读取 google 表格。 初始身份验证设置已完成,我可以阅读相应的表格。 但是当我这样做的时候 sheet.get_all_records()
我刚刚开始使用 Python (v3.8),并尝试将其应用到工作中的实际项目中。我使用了 Google Sheets API 的视频教程,并且能够使用它来操作单元格数据。现在,我尝试使用视频中介绍的语
我使用gspread在Google电子表格上写入数据。它在本地工作正常,但是当我在实时服务器上尝试时,它给了我一个以下错误。 File "/home/openerp10/openerp_7.0/add
我有一个数据列表(从 CSV 中提取),我正在尝试使用 Python/GSpread 更新 Google 文档上的一系列单元格。这是我的代码示例: import gspread def write_s
我当前运行一个守护线程,该线程获取所有单元格值,计算是否有更改,然后在循环中写出依赖单元格,即: def f(): while not event.is_set(): upda
我正在尝试使用Python2.7中的Gspread来检索电子表格。我似乎能够登录,但每当我发出命令时 gc.openall() 它只返回一个空列表。我已授予服务帐户管理员对所有内容的访问权限,并且在我
我正在尝试使用 Gspread 在某个位置插入新列。我找到了 add_cols 方法,但它只插入电子表格的最后一列。 还有其他方法,例如:insert_rows、resize 或 append_row
我正在使用 gspread 更新我的电子表格,这个过程大约需要一个小时,我有大约 200 个电子表格。更新表格大约 30 分钟后,连接断开。有没有办法让登录保持事件状态?我以为我保持连接有效,因为我大
要更新一系列单元格,请使用以下命令。 ## Select a range cell_list = worksheet.range('A1:A7') for cell in cell_list:
我们使用 developers.google.com 创建了 api 用户并将凭据下载为 json 文件。现在在我的 macbook 上,gspread 身份验证在使用 credentials.jso
我是一名优秀的程序员,十分优秀!