3

I'd like to allow a user to visit one of my sites, enter some information into a field, and then save that information into a Google Spreadsheet via JavaScript.

  • I don't want the user to login via Google or have to do any special authentication.
  • It's Ok if the spreadsheet needs to be open to public; the data's not sensitive.
  • I don't want to use a Google Form, I want to have full control over the client-side UI.

I've been reading through the Google developer docs, but they only make mention to an OAuth login solution. The Google Developer Console allows you to create a "Public API access key", but does not explain how it's used.

pinoyyid
  • 21,499
  • 14
  • 64
  • 115
Luke
  • 18,811
  • 16
  • 99
  • 115
  • The current answer is good but if you haven't done something similar before it can de daunting. Instead look at building a webapp with apps script published to run as you. It will take care of all the authentication and so forth. – Zig Mandel Apr 01 '15 at 13:32

1 Answers1

2

All of the examples are for the scenario where the user is using your app to access his own files. In your case, you want the app to access your own file. This isn't easy. The only ways I can see are :-

  1. Use a server app (appengine works well) to do the access
  2. Very carefully set up permissions and store a refresh token in your app.

Option 2 could be your worst security nightmare if you don't do it carefully, and even then may be an infringement of Google T's and C's since it's akin to distributing your password.

Once you figure out the auth, you'll need to check out the spreadsheet API (https://developers.google.com/google-apps/spreadsheets/), as this is the API that allows you to update an existing spreadsheet. The Drive API can only upload an entire new spreadsheet.

pinoyyid
  • 21,499
  • 14
  • 64
  • 115
  • In the Spread Sheet API it is available for Java and .NET ,nothing is specified for java script.Can you please tell me how to add using Javascript – nitesh Apr 09 '15 at 05:22
  • the spreadsheet API is an HTTP REST API that is usable anywhere you can compose an HTTP Post. So in the simplest case new XmlHttpRequest().open('POST', url_from_documentation etc – pinoyyid Apr 09 '15 at 09:40