pythoncredentialsgspreadoauth2client

python gspread, different user authority


I am currently trying to do 2 desktop apps. One for admin another one for user. The goal is to prevent user from editing spread sheets and only admin can edit them. In other words, admin has editor access, user has view access.

What i did is:

For normal user:

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

For admin:

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

I made 2 credentials on google's api console, the first one has view only access, other has editor access. However, the problem here is.

When I tried to run:

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)

From the app that use's Agent_Access.json file, it can edit it. Any idea how to fix this?


Solution

  • So what i found is, when you share your spreadsheet with client_email at .json file, you have to make the share as viewer.