Brady
Brady

Reputation: 322

Authorization for Deployed GAS Web Apps

I'm trying to build a basic deployed web app using Google Apps Script HtmlService. The goal of the app is to house and serve multiple html forms through templates, take the form data, record it, and email it to a designated email address. I've got the app code and UI to work smoothly but am having some service authorization errors:

One of the time saving features the web app employs is that the script uses PropertiesService to store some of each user's basic info so that they don't have to type it in every time. Now that I've deployed the Web app for testing, I am running into authorization errors.

When I personally try to run the script, I can access PropertiesService just fine, no hang ups. When a user who does not have the script shared with them tries to access the service, they get a notification to request access to the script itself, which I don't really want to give everyone in my team access to.

Has any one else tried to use authorized services for a deployed web app and run into similar problems? Do I need to add a special authorization function or script to my app to ensure end-users have the proper access? Should I try another method to accomplish saving/using individual user data?

Any advice would be welcomed.

Here's the code for storibg the user variables:

function processNewUserForm(formObject) {
  var newUserProperties = {
    first: formObject['firstName'],
    last: formObject['lastName'],
    emplid: formObject['EmplID'],
    email: user_email,
    workspace: formObject['Workspace'],
    team: formObject.team,
    username: formObject['Username'],
    computerTag: formObject['Computer Asset Tag']
  };

  try {
    userProperties.setProperties(newUserProperties, false);
  }
  catch(e) {
    sendErrorReport(e);
  }
}

Note: userProperties is defined globally as var userProperties = PropertiesService.getUserProperties();

Upvotes: 1

Views: 159

Answers (1)

Brady
Brady

Reputation: 322

It took me a lot of digging, but I actually found the root cause of the authorization problem. The server-side function I was calling actually contained several Logger.log(var1iable) references which was great for debugging but needed edit access to the script to run. I removed the Logger references and the app is now functioning as expected.

Upvotes: 1

Related Questions