本文介绍了Google Apps脚本oAuth onOpen授权的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我使用Google电子表格作为模板,在提交表单时将其复制.该电子表格具有几个自定义功能.

I'm using a Google spreadsheet as a template that is copied at form submission. This spreadsheet has several custom functions.

在从模板复制的电子表格上,我遇到了两个问题:

I've run into two problems on spreadsheets copied from the template:

  1. 自定义菜单功能,允许用户创建活动工作表的PDF,无法从前端进行授权-它只是挂起.看来oAuth授权只能从代码编辑器中进行,我不能期望用户这样做.

  1. A custom menu function that allows the user to create a PDF of the active sheet cannot be authorized from the front end -- it simply hangs. It appears oAuth authorization can only occur from the code editor, which I can't expect users to do.

用户将单击自定义菜单功能,获得授权对话框,进行授权,然后忘记再次单击以运行该功能.

Users will click a custom menu function, get the authorization dialog, authorize, then forget to click again to run the function.

打开工作表后,是否可以让用户授权所有功能,包括oAuth(用于PDF创建)?

Is there a way to have users authorize all functions, including oAuth (for PDF creation), as soon as they open the sheet?

推荐答案

以防万一有人发生在我身上,我想我找到了答案:

Just in case someone else happens upon this, I think I found my answer:

似乎无法从前端对使用oAuth的功能进行授权.除非您想编写自己的授权流程,否则Google似乎无意在将来提供它.我,一个,不要.

It appears that functions using oAuth can't be authorized from the front-end. It also appears that Google has no intention of making it available in the future unless you want to write your own authorization flow. I, for one, do not.

但是,我确实找到了解决方法.通过将需要授权的功能包含在库中并将该库包含在脚本中,无论有多少电子表格调用该功能,用户只需授权一次即可.

I did, however, find a work-around. By including the functions that need authorization in a library and including that library in your script, users only need to authorize a function once, no matter how many spreadsheets call the function.

我的组织中只有12位用户,因此我很容易理解这一点-我可以访问他们的每台计算机,并对库中的功能进行一次授权,仅此而已.

There are only 12 users in my organization, so I got off easy on this one -- I can go to each of their computers and authorize the functions in the library once, and that's that.

希望这对某人有帮助!

这篇关于Google Apps脚本oAuth onOpen授权的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 23:32