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

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

问题描述

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

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开发者控制台,您可以创建公共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.云端硬盘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天全站免登陆