How can I validate a google sheet comes from a specific workspace and is not public?

Viewed 50

In my application, I am allowing a user to input a sheet URL and then my application pulls in information from the sheet as well as allow them to append some values to the sheet.

This is all meant to be done in a specific google workspace. I would like to validate that the sheet the user imported comes from the google workspace I am expecting and is not public.

I am not sure if this is possible or not. I have scoured the Google developer docs around sheets and I haven't found any related questions on SO.

Is there any way to achieve that?

1 Answers

The closest thing is using the spreadsheets.get method from the API in order to see if you are able to retrieve the content of the sheet. You will receive a 200 response if you at least have access to the file, otherwise you will get a 403 error saying that you do not have permissions to read the file.

References:

Related