Access Google Spreadsheet API Without Oauth Token


Answer :

API key is not enough. You're trying to use spreadsheets.values.append which requires OAuth authorization:

Authorization Requires one of the following OAuth scopes:

https://www.googleapis.com/auth/drive https://www.googleapis.com/auth/drive.file https://www.googleapis.com/auth/spreadsheets For more information, see the [Auth Guide](https://developers.google.com/identity/protocols/OAuth2). 

Note it says OAuth.


You could use the format as below:

https://docs.google.com/spreadsheets/d/{sheetID}/export?format=csv

Make a URLConnection to this URL, after replacing the sheetID with your public sheet and read the csv file as you would normally do in your programming language of choice.

Please note that this is only true for Readable Public Google spreadsheets, and is a bit of a hack when you don't necessarily need to do the Credentials jig and jive


In my case I need to publish content from a Google Spreadsheet to a web page. My workaround consists in use the HTTP GET call

GET https://sheets.googleapis.com/v4/spreadsheets/{spreadsheetId}/values/{range}

using the javascript object XMLHttpRequest In this solution you only have to use the API key


Comments

Popular posts from this blog

Are Regular VACUUM ANALYZE Still Recommended Under 9.1?

Can Feynman Diagrams Be Used To Represent Any Perturbation Theory?