python gspread,不同的用户权限

python gspread, different user authority

我目前正在尝试开发 2 个桌面应用程序。一个给管理员,另一个给用户。目标是防止用户编辑电子表格,只有管理员可以编辑它们。换句话说,管理员有编辑权限,用户有查看权限。

我做的是:

对于普通用户:

creds = ServiceAccountCredentials.from_json_keyfile_name(
    'Agent_Access.json', scope)

对于管理员:

creds = ServiceAccountCredentials.from_json_keyfile_name(
        'editor.json', scope)

我在 google 的 api 控制台上创建了 2 个凭据,第一个具有仅查看权限,另一个具有编辑器权限。然而,这里的问题是。

当我尝试 运行 时:

sheet = client.open('my test sheet')
worksheet = sheet.get_worksheet(0)
worksheet.update_acell('B4','Viral2') 
# Edit was successfully done from user side(This edit should not work)

从使用 Agent_Access.json 文件的应用程序中,它可以对其进行编辑。知道如何解决这个问题吗?

所以我发现,当您在 .json 文件中与 client_email 共享您的电子表格时,您必须以查看者身份进行共享。