使用公共 API 访问(无 OAuth)从 JavaScript 写入 Google 电子表格 [英] Write to a Google spreadsheet from JavaScript using the Public API access (no OAuth)

查看:28
本文介绍了使用公共 API 访问(无 OAuth)从 JavaScript 写入 Google 电子表格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望允许用户访问我的网站之一,在字段中输入一些信息,然后通过 JavaScript 将该信息保存到 Google 电子表格中.

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.

  • 我不希望用户通过 Google 登录或必须进行任何特殊身份验证.
  • 如果电子表格需要向公众开放也没关系;数据不敏感.
  • 我不想使用 Google 表单,我想完全控制客户端 UI.

我一直在阅读 Google 开发者文档,但是他们只提到 OAuth 登录解决方案.Google Developer Console 允许您创建公共 API 访问密钥",但没有解释它是如何创建的用过.

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.

推荐答案

所有示例均针对用户使用您的应用访问他自己的文件的场景.在您的情况下,您希望应用程序访问您自己的文件.这并不容易.我能看到的唯一方法是:-

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. 使用服务器应用(appengine 运行良好)进行访问
  2. 非常仔细地设置权限并在您的应用中存储刷新令牌.

如果您不小心执行,选项 2 可能是您最糟糕的安全噩梦,即使那样也可能侵犯 Google T 和 C,因为它类似于分发您的密码.

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.

确定身份验证后,您需要查看电子表格 API (https://developers.google.com/google-apps/spreadsheets/),因为这是允许您更新现有电子表格的 API.Drive API 只能上传一个全新的电子表格.

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.

这篇关于使用公共 API 访问(无 OAuth)从 JavaScript 写入 Google 电子表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆