1

Background: I know it is possible to read/write data from/to a Google sheet using the JavaScript API. I know it is possible to do it with an API key paired with oAuth (because the service has to know who the user is, which really means being a google user).

However, the question that Google does not address clearly (and I find the documentation misleading):

Can a JavaScript app/webpage have write permission to a google sheet (that is public open access) WITHOUT having to provide an oAuth client ID?

Everything I tried and researched leads to no, you cannot - you have to provide a client ID. Also I find the Service Account method not applicable for JS API via a web page.

Am I missing totally missing something? Please let me know if you have any specific insight into the above.

I solved it by having middleware php code that takes data from the webpage and uses a Service Account to communicate with the Google sheet, then returns data to the webpage. So... my question re-phrased: can I do the above directly without php?

  • Is the Google sheet public or private? – zipzit Mar 01 '22 at 14:54
  • 1
    I've no idea, to be honest. But I suppose that there is no way to do it without oAuth, otherwise creating bots that mess up random public sheets would be too easy – Christian Vincenzo Traina Mar 01 '22 at 14:55
  • is it to access the sheets in ur account or of the users? – Joel Mar 01 '22 at 15:12
  • Have you checked the [Authorizing requests](https://developers.google.com/sheets/api/guides/authorizing) when using Sheets API? that documentation may give you an idea about what type of authorization is needed for your app. – Gabriel Carballo Mar 02 '22 at 00:45

1 Answers1

0

After testing it seems that there is no way to use Sheets API without getting some sort of consent being either through a consent screen or by using an API Key, your code will either have to show a consent screen to grant authorization or as you are currently doing, perform domain wide authority with domain wide delegation.

Gabriel Carballo
  • 1,278
  • 1
  • 3
  • 9