コンピュータや音楽の事書いてます

Google Spreadsheetで「You do not have permission to call 〜」

これを使って

CalendarApp.getCalendarById("ja.japanese#holiday@group.v.calendar.google.com");
holidays = calendar.getEvents(startDate, endDate);

をonEditから起動し、日本の祝日を取得しようと思ったら、"You do not have permission to call getCalendarById"という例外が発生した。
理由は https://developers.google.com/apps-script/guides/sheets/functions に書いてあった。

If your custom function throws the error message You do not have permission to call X service., the service requires user authorization and thus cannot be used in a custom function.

To use a service other than those listed above, create a custom menu that runs an Apps Script function instead of writing a custom function. A function that is triggered from a menu will ask the user for authorization if necessary and can consequently use all Apps Script services.

onEditやonOpenからの起動では許可されず、custom menuからの呼び出しじゃないと許可されないらしい。。。。もっと目立つところに書いてくれよ。。。。
https://developers.google.com/apps-script/guides/menus