Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I enable permissions to FormApp?

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...

like image 647
Vidur Avatar asked Nov 19 '18 14:11

Vidur


2 Answers

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.

like image 118
Vidur Avatar answered Nov 10 '22 01:11

Vidur


Put

FormApp.getActiveForm();

in the first line of your function you're calling and manually call that function from editor. It asks you for permissions before it realises you're calling it from the editor.

like image 22
John Avatar answered Nov 09 '22 23:11

John