CalendarApp.getDefaultCalendar() authorization

北城以北 提交于 2019-12-12 02:27:58

问题


I wrote a script in a spreadsheet, which shall create a calender event. Coming down to the statement

var cal = CalendarApp.getDefaultCalendar();

I get the error "Authorization failed" ( Ausführung fehlgeschlagen: Sie haben nicht die erforderliche Berechtigung zum Aufruf von getDefaultCalendar. (line 107, file "Kopie von Code") [0.171 Sekunden Laufzeit insgesamt] )

What can I do to get this authorization? I'm the same user on the Google Drive and Google Calendar.


回答1:


From Google App Script's Troubleshooting section:

Authorization is required to perform that action. This error indicates that the script is lacking the authorization needed to run. When a script is run in the Script Editor or from a custom menu item an authorization dialog is presented to the user. However, when a script is run as a service, embedded with a Google Sites page, or run from a trigger the dialog cannot be presented and this error is shown. To authorize the script, open the Script Editor and run any function. To avoid this error, remember to run the script once in the Script Editor after adding new services or capabilities to your script.

Just run any one function of your script from the Run menu and the Script Editor should present the dialog to grant authorization. After that your script should work.



来源:https://stackoverflow.com/questions/19079111/calendarapp-getdefaultcalendar-authorization

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!