4

I am building a python app where user can provide 'Anyone can edit' link to their spreadsheet and data can be read from there. I am using python's gspread module but it throws SpreadSheetNotFound error.

import gspread
from oauth2client.service_account import ServiceAccountCredentials
scope = ['https://spreadsheets.google.com/feeds']
credentials = ServiceAccountCredentials.from_json_keyfile_name('myauth.json', scope)
gc = gspread.authorize(credentials)
wks = gc.open_by_url(urls_given_by_user_having_edit_permission)

Above code is not working. Is there any way to achieve this?

deffy50
  • 93
  • 7
  • Could you share the `urls_given_by_user_having_edit_permission` format? Just to give a general idea of a value. You may omit some characters if you'd like to hide the real value. – Burnash Nov 21 '16 at 11:01
  • @Burnash its like https://docs.google.com/spreadsheets/d/1N0_Ao-U2Euub0_cadx44R3EPMpEC0KUJW-t3E where value after d/ is the key. I am searching for any way to get the above task done, not stringent on gspread. – deffy50 Nov 21 '16 at 12:35
  • did you try to open the spreadsheet by key? https://github.com/burnash/gspread#opening-a-spreadsheet – Burnash Nov 21 '16 at 16:50
  • another possible solution is to access your spreadsheets via json interface: https://spreadsheets.google.com/feeds/list//od6/public/values?alt=json for list, and https://spreadsheets.google.com/feeds/cells//od6/public/values?alt=json for cells – Burnash Nov 21 '16 at 17:00
  • @Burnash by key extracts key from url, that's it and that didn't work as well. Feeds will give spreadsheets from out own account, isn't it? I was looking to access doc of another user that is shared with edit permission. – deffy50 Nov 22 '16 at 08:55
  • You're right, it won't work with public sheets. Only with private sheets _shared_ with client email address. Did you try accessing your spreadsheets with json api links? – Burnash Nov 22 '16 at 19:01
  • did you ever find a solution? – SantoshGupta7 Jan 02 '20 at 10:30

1 Answers1

0

wks.share('', perm_type='anyone', role='reader')

Read permission for all people with link. reference https://gspread.readthedocs.io/en/latest/api.html#gspread.models.Spreadsheet.share

britodfbr
  • 1,747
  • 14
  • 16