Google Drive API: can't read doc owned by other user

Viewed 37

I'm trying to read some Google Doc using the gspread client (Python).

I have instanciated a gspread.Client using the scope https://www.googleapis.com/auth/drive.file and an oauth token for my account.

I tried opening two different files, only the first one (file that I own) can be read this way.

The second file (which is shared with me through a group and I can open in the web app) fails to be read:

>>> gc.open_by_key("171b...") # I created this file
<Spreadsheet ...>
>>> gc.open_by_key("1ehE...") # This file is shared with me
gspread.exceptions.APIError: {'code': 404, 'message': 'Requested entity was not found.', 'status': 'NOT_FOUND'}

What can be the reason for that?

1 Answers

This problem was solved after requiring the scope https://www.googleapis.com/auth/drive.readonly when authenticating the user.

Related