Google Apps脚本日历授权要求循环 [英] google apps script calendar authorization required loop

查看:395
本文介绍了Google Apps脚本日历授权要求循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个电子表格存储来自表单的数据。一旦数据提交表单提交我有一个脚本运行,使用谷歌地图和电子邮件相关信息的相关利益相关者进行一些距离计算。

i have a spreadsheet which stores data from a form. once data is submitted on form submit i have a script running that does some distance calculations using google maps and emails relevant information to the relevant stakeholders.

脚本也在具有某些数据的电子表格中的列上运行,然后再次向相关利益相关者发送相关信息,并且应该在默认日历中创建事件。

script is also run upon a column in the spreadsheet having certain data which then again emails the relevant information to the relevant stakeholders and is supposed to create an event in the default calendar.

脚本已经正常工作,但自从我插入calendarapp.getdefaultcalendar开始创建事件,我继续获得授权所需的屏幕,提示我脚本将管理我的日历,查看和管理我的电子表格,以我的身份发送电子邮件并连接到外部服务。这是所有罚款,我接受提示,除非它不断回来一遍又一遍。

script has been working fine but ever since i have inserted the calendarapp.getdefaultcalendar to start creating events i keep getting the authorization required screen prompting me that the script would to manage my calendars, view and manage my spreadsheets, send email as me and connect to external services. this is all fine and i accept the prompt except it keeps coming back up over and over again.

任何建议,请帮助。我有一个类型的配额,是什么?

any suggestions please help. have i reached a some type of quota, what is it?

function myFunction() {

  var DISTANCE_COLUMN = 14;
  var DURATION_COLUMN = 15;
  var COST_COLUMN = 16;
  var ROUTE_COLUMN = 17;
  var STATE_COLUMN = 18;
  var BOOKED_COLUMN = 19;

  var EMAILED_STATE = "EMAILED";
  var BOOKED_STATE = "BOOKED";

  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getSheets()[0]; // gets sheet 0 from active spreadsheet

  var data = getRowsData(sheet); // gets all the data from the active spreadsheet using 
                                 // the getRowsData function below 

  for (var i = 0; i < data.length; i++) { // for every row within the active spreadsheet
  var row = data[i];

  row.rowNumber = i + 2;

if(!row.distance) { // check to see if distance already exists
  var mapsURL = 'http://maps.google.com/maps/api/directions/xml?origin=' + row.pickUpAddress + ' Victoria&destination=' + row.dropOffAddress + ' Victoria&sensor=false&units=metric&mode=driving';
  var mapsXML = UrlFetchApp.fetch(mapsURL).getContentText();
  var mapsResponse = Xml.parse(mapsXML, true);
  var distance = mapsResponse.DirectionsResponse.route.leg.distance.getElement("value").getText();
  var duration = mapsResponse.DirectionsResponse.route.leg.duration.getElement("value").getText();

  var distance = Math.round(distance / 1000); // convert distance in to kilometers
  var duration = Math.round(duration / 60); //convert duration in to minutes
  var cost = 0;


  // Changes the date fields in to strings so that we can compare for tarif one. 
  var formattedPickUpTime = Utilities.formatDate(row.pickUpTime, "GMT+1000", "HHmmss");
  var formattedFromTime = Utilities.formatDate(new Date("12/30/1899 23:00:00"), "GMT+1100", "HHmmss");
  var formattedToTime = Utilities.formatDate(new Date("12/31/1899 04:00:00"), "GMT+1100", "HHmmss");


  var mapsRoute = '"http://maps.google.com/maps?f=d&source=s_d&saddr=' + row.pickUpAddress + ' Victoria&daddr=' + row.dropOffAddress + ' Victoria&mode=driving"';

  sheet.getRange(row.rowNumber, DISTANCE_COLUMN).setValue(distance); // set distance value
  sheet.getRange(row.rowNumber, DURATION_COLUMN).setValue(duration); // set duration value
  sheet.getRange(row.rowNumber, COST_COLUMN).setValue(cost); // set cost value
  sheet.getRange(row.rowNumber, ROUTE_COLUMN).setValue(mapsRoute); // set map of route value
}

if(!row.state) { // check to see if emails have already been sent
  stakeholderEmailFYI(row, distance, duration, cost, mapsRoute); // send an FYI email to the stakeholder
  // customerEmailConfirmation(row); // send a confirmation email to the customer
  sheet.getRange(row.rowNumber, STATE_COLUMN).setValue(EMAILED_STATE); // change state value to SENT      
}

if(row.sendBooking == "Y") { // check to see if emails have already been sent
  // customerEmailConfirmation(row); // send a confirmation email to the customer

  var eventStartTime = row.pickUpTime;
  // End time is calculated by adding an hour in the event start time
  var eventEndTime = new Date(row.pickUpTime.valueOf()+60*60*1000);

  var cal = CalendarApp.getDefaultCalendar().createEvent(row.fullName, eventStartTime, eventEndTime, {location: row.pickUpAddress});

  // cal.createEvent(row.fullName, eventStartTime, eventEndTime, {location: row.pickUpAddress});
  sheet.getRange(row.rowNumber, BOOKED_COLUMN).setValue(BOOKED_STATE); // change state value to SENT
}
}
}


推荐答案

尝试撤销授权并重新授权脚本,有时它会解决问题。

Try to revoke authorizations and re-authorize the script, sometimes it solves the problem.


  1. 您收到一封邮件告诉您授权此应用程式,这封邮件有一个自动解除安装功能的连结应用由其他人或您的其他帐户撰写

  2. 您知道脚本的名称,并且没有这么多脚本,请转到您的Google个人资料/安全/撤销权限,有一个列出您授权的所有脚本和每个脚本卸载的按钮。

  3. (是的,我知道我说2)使用您的脚本的url如下所示:

  1. You have received a mail telling you you authorized this app, this mail has a link to an automatic uninstall feature (but this is when the app is written by someone else or another of your accounts
  2. You know the name of the script and you don't have so much scripts, go to your Google profile/security/revoke access , there is a list of all the scripts you authorized and a button for each of them to uninstall.
  3. (Yes I know I said 2 :) use the url of your script which is something like below :

https://script.google.com/macros/d/ MZMgUL88c4hd6qj_G2Y7-rKtIT_UhbT9n /编辑UIV = 2及?TZ =欧洲/布鲁塞尔和放大器; docTitle =测试+申通快递和放大器; CSID = tAeLIRLHehPkQGfa6zUYzpg.11577354092571548890.6605670643166911759&安培;中端= ACjPJvG-INu6kmfFfm649tuH-6KYNVpaz5G9uEy4CUMmcKAVn7RYVi8euALNy9dfPWl6gkCloq5D6SKrqczHteazKR2F41v5K5bqbw和放大器; HL = EN_US

删除/ edit?...包括/ edit?之后的所有内容

remove everything after "/edit?..." including "/edit?"

并添加 / manage / uninstall

,使其变成这样:

https://script.google .com / macros / d / MZMgUL88c4h_G2Y7-rKtIT_UhbT9n / manage / uninstall

这将带您进入如下页面:

This will bring you to a page like this one :

>

点击卸载并完成... ...处女作为处女...

Click uninstall and your done... virgin as a virgin...

然后重新授权查看是否会更好。

Then re-authorize to see if things go better.

这篇关于Google Apps脚本日历授权要求循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆