将私人数据导入Google电子表格 [英] Import private data into Google Spreadsheet

查看:145
本文介绍了将私人数据导入Google电子表格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用函数ImportXML将私人数据导入Google Spreadsheet。为了完成这项工作,我编写了一个API。然而,由于私人数据我想使API保密。我可以做到这一点。问题的关键在于这样做,以便Google Spreadsheet可以与我的自定义API进行通信。



最好,我希望在用户登录到Google时使用OAuth 2.0电子表格。这可能吗?



欢迎您提供其他建议。 是可能的。首先,让您的自定义API使用Google身份验证。



在Google电子表格中的Google Apps脚本中


  1. 获取URI以使用您的API初始化auth
  2. 按照重定向

执行这两个步骤,您将收到某种令牌,以证明您已登录。请使用此方法,然后联系API获取数据。

请注意,如果您使用安装的应用程序,用户身份验证将安装应用程序,而不是打开电子表格的人。如果您不使用已安装的应用程序,则无法自动执行此操作,因此您打开电子表格是因为未安装的应用程序无法在onOpen()方法中进行身份验证。所以你将不得不使用菜单项,按钮或任何手动执行该功能。


I am importing private data into Google Spreadsheet using the function ImportXML. To make this work, I have written an API. However, since the data in private I would like to make the API private. I can do that. The problem is to do it in a way so that Google Spreadsheet can communicate with my custom API.

Preferably, I would like to use OAuth 2.0 with the user logged into Google Spreadsheet. Is this possibly?

Other suggestions are welcome.

解决方案

This is possibly. First, make your custom API use Google auth.

In a Google Apps Script in your Google Spreadsheet

  1. Fetch the URI to initialize auth with your API
  2. Follow the redirect

Doing these two steps you recieve some kind of token to prove you are logged in. Use this then contacting the API for data.

Be advised, if you use an installed app, the user authenticating will be the one who installed the app, not the one opening the spreadsheet. If you do not use an installed app, you can not do this automatically then you open the spreadsheet because non-installed apps cannot authenticate in the onOpen() method. So you would have to use a menu item, a buttom or whatever to execute the function manually.

这篇关于将私人数据导入Google电子表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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