如何启用对FormApp的权限? [英] How do I enable permissions to FormApp?

查看:113
本文介绍了如何启用对FormApp的权限?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个Google Apps脚本,我想在其中使用FormApp服务来获取活动表单,但是该脚本不断抛出异常:

You do not have permission to call FormApp.getActiveForm. Required permissions:
(https://www.googleapis.com/auth/forms.currentonly ||
https://www.googleapis.com/auth/forms) (line 7, file "Code")

我已经启用了对Google Drive API和Google Sheets API的权限-但在Google Cloud Platform API仪表板的任何位置都找不到标有"Forms"的API.

Google搜寻并没有提供任何有用的信息,只是提供了指向API文档的更多链接.

您知道对API FormApp进行分类的依据吗?

我不想启用每个API来查找...

解决方案

对于以后遇到这篇文章的人,我通过将以下内容手动添加到清单文件中解决了我的问题:

"oauthScopes": [
    "https://www.googleapis.com/auth/forms",
    "https://www.googleapis.com/auth/spreadsheets"
],

您可以通过单击View > Show Manifest File找到清单文件-这将在侧边栏中显示一个名为appscript.json的文件.

然后单击Run或工具栏中的播放按钮-这将迫使该应用查看权限并提示您使用帐户进行授权.

注意:@tehhowch在下面指出的一个好处是,将其手动添加到清单中将禁用范围的自动检测.我的自动检测似乎仍然无法正常工作,因此我采用了这种手动解决方案-只是警告一下.

I am creating a Google Apps script in which I want to use the FormApp service to get the active form, however it keeps throwing an exception:

You do not have permission to call FormApp.getActiveForm. Required permissions:
(https://www.googleapis.com/auth/forms.currentonly ||
https://www.googleapis.com/auth/forms) (line 7, file "Code")

I have enabled permissions to both Google Drive API, and to Google Sheets API - but can't find an API labeled as "Forms" anywhere in the Google Cloud Platform API Dashboard.

Googling has not turned up anything useful, just more links to the API documentation.

Any idea which API FormApp is classified under?

I don't want to have to enable every single API to find out...

解决方案

For future people who come across this post, I resolved my issue by manually adding the following to my Manifest file:

"oauthScopes": [
    "https://www.googleapis.com/auth/forms",
    "https://www.googleapis.com/auth/spreadsheets"
],

You can find your Manifest file by clicking on View > Show Manifest File - this will make a file called appscript.json appear in your sidebar.

Then click Run or the play button in the toolbar - which will force the app to review permissions and prompt you to authorize with your account.

Note: A good point that @tehhowch has pointed out below is that adding this manually to your manifest will disable auto-detection of scopes. My auto-detection doesn't seem to be working correctly anyway, so I've gone ahead with this manual solution - just a word of warning.

这篇关于如何启用对FormApp的权限?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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