AFAIK, you need to publish your spreadsheets to the web so you can access its contents.
As stated in the Sheets API URLs, visibilities, and projections , the public visibility is supported for spreadsheets that have been "Published to the Web".
Please note of the given warnings:
API requests using the public visibility for feeds on spreadsheets that are not "Published to the Web" yield an HTTP 400 Bad Request response The spreadsheet at this URL could not be found. Make sure that you have the right URL and that the owner of the spreadsheet hasn't deleted it.
The public visibility does not work for spreadsheets that are made "Public on the web" from the "Visibility options" portion of the sharing dialog of a Google Sheets file. "Published to the web" and "Public on the web" are different ways to share a spreadsheet. We are aware that this is confusing, and will address it in a future version of the API. For now, we hope that this detailed warning prevents confusion.
If your looking for ways to programmatically publish your Google Docs, you may set published
property to true
using Revisions.update.
This related SO thread might also help but it's done in JS.