3

I have an add-on which requires access to various Google services, and requests the following access when initially loaded:

enter image description here

I also have a webapp which runs as me (the same google account as the add-on) and can be accessed by anyone including anonymous. The webapp trys to access a form which I believe I should already have access to.

Webapp:

function doGet(){
  var form = FormApp.openById('');
  var formId = form.getId();
  var items = form.getItems();
  return ContentService.createTextOutput("Form contains "+items.length+"items.");
}

Error:

No item with the given ID could be found, or you do not have permission to access it.

Question:

When the add-on initially requests access to the user's Drive, does this give access to the add-on only or to the developers google account?

beano
  • 932
  • 1
  • 15
  • 28
  • Try opening the script and running any function as the user who published the web-app. Might be an issue with you not having given the script the proper authorizations. If you have made any changes since you published it you may need to re-authorize, or maybe even re-publish under a new version number. – Jonathan Seed Jul 31 '15 at 19:51

2 Answers2

11

I had the same problem, the problem was the ID, in order to fix the problem you need to pass the edit ID of the form. I've attached a picture to further describe. enter image description here

deepGrave
  • 320
  • 3
  • 11
0

The error occurs because on the following line:

var form = FormApp.openById('');

The openById parameter is ''. It will be solved by passing the form ID.

You could get the form ID from the URL or by using getId().

Related Q&A

Rubén
  • 34,714
  • 9
  • 70
  • 166
  • 1
    My thought is that the actual id was removed from the posted code for privacy reasons. But with no response from @beano, no way to know for sure. – tehhowch Apr 28 '18 at 12:46