Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

You do not have permission to perform that action

I have a time-triggered script that periodically retrieves content from an external source and updates a Google sites page with it. According to this, the script should be running under my account, which has full assess to that Google site page (tested by manually editing it). But when I run the script, I get the

You do not have permission to perform that action.

Why do I not have that permission when running the script, if I can edit the page manually?

Here is the (generalized) script function:

function updatePage() {
  var site = 'https://sites.google.com/a/mydomain.com/myhome/mypagegroup/mypage';
  var pageName = '/mypagegroup/mypage';

  var site = SitesApp.getSiteByUrl(site);
  var page = site.getChildByName(pageName); //works fine
  Logger.log('page: ' + page.getTitle()); //displays correct page title

  var html = '<p>'; //in actual script, I get html from external source

  Logger.log('html: ' + html);

  page.setHtmlContent(html); //this is where the error is generated ("You do not have permission to perform that action")
};
like image 895
Boris Avatar asked Jan 28 '15 19:01

Boris


1 Answers

In the script editor, did you choose the function name from the drop down list, and click the run icon?

update Page

The first time you run it this way, a pop up will display, stating that authorization is needed. You must give authorization to modify sites. If that hasn't been done, you'll get an error.

Authorization Required

Authorize sites:

Manage Sites

I ran your code, after authorizing the script, and it worked.

You can go into your account, and check what projects you have given permissions to. You need to choose "Account", and then click "Get Started" in the Security checkup section of the Account settings window.

like image 89
Alan Wells Avatar answered Oct 09 '22 02:10

Alan Wells