Google Script完整帐户访问权限

问题描述 投票:0回答:1

所以,我正在编写一个Google Apps脚本,但每次我更改脚本以执行新的操作时,都需要重新授权。有没有办法“预授权”脚本的所有这些权限,以便您不再需要提示?

我知道可以给予应用程序的最高级别权限是“完全帐户访问权限”,因此如果有人知道如何为脚本提供该级别的权限,我将非常感谢您找到答案。

google-apps-script permissions google-apps
1个回答
3
投票

如果您真的想要一次性获得几乎所有内容的脚本,请继续阅读!

提供无意识授权与Google的安全策略不一致,因此您可以在任何地方找到按钮。但你是对的 - 包含每个API调用的脚本将触发每个特定的授权。

您可以浏览文档并查找每个方法,甚至使用自动完成来获取所有方法,但这是一个自动化过程的技巧。

所有Google Apps服务都是this对象的属性,它们的方法又是它们的属性。因此,您可以遍历this对象定义以构建所有GAS方法的列表,并组装包含所有这些方法的函数,仅用于一次通过超级授权。

码:

function buildauthFuncInside() {
  var authFuncInside = "return;";  // safety in case someone calls the function
  for (var maybeService in this) {
    if (typeof this[maybeService] !== 'object') continue;
    var service = this[maybeService];
    var serviceName = service.toString();
    if (serviceName == 0) continue;  // Skip 'funny' functions, like "BigNumber"
    for (var maybeFunction in service) {
      if (typeof service[maybeFunction] == 'function') {
        // Note: name is a non-standard property of function objects
        authFuncInside += serviceName+"."+service[maybeFunction].name+"();"
      }
    }
  }
  var authFunc = "function authFunc() {"+authFuncInside+"}";

  // Copy the value of authFunc from the debugger, paste into the editor,
  // remove the quotes, and you have a super-authorization function.
  debugger;
}

此函数构建一个字符串,其中包含每个已知方法的函数,不包括高级服务。将代码粘贴到脚本中,在调试模式下运行,并准备好在最后暂停。

正如评论所说:从调试器复制authFunc的值,粘贴到编辑器中,删除引号,并且您具有超级授权功能。今天,这是你得到的:

function authFunc() { Browser.msgBox(); Browser.toString(); Browser.inputBox(); CacheService.getUserCache(); CacheService.getScriptCache(); CacheService.getDocumentCache(); CacheService.getPrivateCache(); CacheService.toString(); CacheService.getPublicCache(); CalendarApp.getTimeZone(); CalendarApp.createEventSeries(); CalendarApp.isMyPrimaryCalendar(); CalendarApp.createAllDayEvent(); CalendarApp.subscribeToCalendar(); CalendarApp.setColor(); CalendarApp.getEventSeriesById(); CalendarApp.setHidden(); CalendarApp.getTitle(); CalendarApp.newRecurrence(); CalendarApp.getAllOwnedCalendars(); CalendarApp.getOwnedCalendarById(); CalendarApp.getId(); CalendarApp.setTimeZone(); CalendarApp.getColor(); CalendarApp.getDescription(); CalendarApp.getDefaultCalendar(); CalendarApp.getEventsForDay(); CalendarApp.openByName(); CalendarApp.createCalendar(); CalendarApp.getAllCalendars(); CalendarApp.openByEmailAddress(); CalendarApp.getCalendarById(); CalendarApp.getOwnedCalendarsByName(); CalendarApp.createAllDayEventSeries(); CalendarApp.isHidden(); CalendarApp.createEvent(); CalendarApp.getEvents(); CalendarApp.isSelected(); CalendarApp.setDescription(); CalendarApp.getName(); CalendarApp.toString(); CalendarApp.setName(); CalendarApp.createEventFromDescription(); CalendarApp.getCalendarsByName(); CalendarApp.isOwnedByMe(); CalendarApp.setSelected(); Charts.newTextStyle(); Charts.newDashboardPanel(); Charts.newColumnChart(); Charts.newScatterChart(); Charts.newNumberRangeFilter(); Charts.newTableChart(); Charts.newPieChart(); Charts.newDataViewDefinition(); Charts.newCategoryFilter(); Charts.newStringFilter(); Charts.newAreaChart(); Charts.newDataTable(); Charts.toString(); Charts.newBarChart(); Charts.newLineChart(); ContactsApp.getContactsByPhone(); ContactsApp.getContactsByCustomField(); ContactsApp.getContactsByAddress(); ContactsApp.deleteContact(); ContactsApp.getAllContacts(); ContactsApp.getContactGroupById(); ContactsApp.findContactGroup(); ContactsApp.getContactsByDate(); ContactsApp.createContact(); ContactsApp.getContactsByNotes(); ContactsApp.getContactsByIM(); ContactsApp.getContactsByUrl(); ContactsApp.getContacts(); ContactsApp.getContactsByEmailAddress(); ContactsApp.findByEmailAddress(); ContactsApp.getContactsByGroup(); ContactsApp.getContactsByCompany(); ContactsApp.getContact(); ContactsApp.deleteContactGroup(); ContactsApp.getContactGroups(); ContactsApp.getContactGroup(); ContactsApp.createContactGroup(); ContactsApp.getContactsByJobTitle(); ContactsApp.getContactsByName(); ContactsApp.toString(); ContactsApp.getContactById(); ContentService.createTextOutput(); ContentService.toString(); DocumentApp.getUi(); DocumentApp.openByUrl(); DocumentApp.toString(); DocumentApp.getActiveDocument(); DocumentApp.create(); DocumentApp.openById(); Drive.removeFolder(); Drive.getFolders(); Drive.getFolderById(); Drive.getTrashedFiles(); Drive.addFolder(); Drive.addFile(); Drive.searchFolders(); Drive.createFolder(); Drive.getTrashedFolders(); Drive.getStorageLimit(); Drive.createFile(); Drive.getFilesByType(); Drive.removeFile(); Drive.getFileById(); Drive.continueFileIterator(); Drive.getFilesByName(); Drive.getFiles(); Drive.getRootFolder(); Drive.getFoldersByName(); Drive.toString(); Drive.getStorageUsed(); Drive.continueFolderIterator(); Drive.searchFiles(); FormApp.getActiveForm(); FormApp.getUi(); FormApp.openByUrl(); FormApp.toString(); FormApp.create(); FormApp.openById(); GmailApp.getAliases(); GmailApp.moveThreadToInbox(); GmailApp.getMessagesForThread(); GmailApp.markMessageUnread(); GmailApp.getPriorityInboxUnreadCount(); GmailApp.search(); GmailApp.markThreadRead(); GmailApp.markMessagesUnread(); GmailApp.markThreadsUnread(); GmailApp.getThreadById(); GmailApp.markThreadsRead(); GmailApp.refreshThread(); GmailApp.getMessageById(); GmailApp.markMessageRead(); GmailApp.getUserLabels(); GmailApp.refreshThreads(); GmailApp.toString(); GmailApp.sendEmail(); GmailApp.unstarMessage(); GmailApp.moveThreadToSpam(); GmailApp.getTrashThreads(); GmailApp.markThreadUnimportant(); GmailApp.getUserLabelByName(); GmailApp.moveThreadToArchive(); GmailApp.getSpamThreads(); GmailApp.moveThreadToTrash(); GmailApp.moveThreadsToArchive(); GmailApp.starMessages(); GmailApp.moveMessagesToTrash(); GmailApp.deleteLabel(); GmailApp.getMessagesForThreads(); GmailApp.moveMessageToTrash(); GmailApp.getSpamUnreadCount(); GmailApp.refreshMessages(); GmailApp.markThreadUnread(); GmailApp.getDraftMessages(); GmailApp.moveThreadsToSpam(); GmailApp.unstarMessages(); GmailApp.getChatThreads(); GmailApp.getPriorityInboxThreads(); GmailApp.markThreadImportant(); GmailApp.getStarredThreads(); GmailApp.getInboxThreads(); GmailApp.createLabel(); GmailApp.starMessage(); GmailApp.moveThreadsToInbox(); GmailApp.markThreadsUnimportant(); GmailApp.moveThreadsToTrash(); GmailApp.markThreadsImportant(); GmailApp.refreshMessage(); GmailApp.getInboxUnreadCount(); GmailApp.getStarredUnreadCount(); GmailApp.markMessagesRead(); GroupsApp.getGroupByEmail(); GroupsApp.getGroups(); GroupsApp.toString(); HomeroomService.toString(); HtmlService.createTemplateFromFile(); HtmlService.getUserAgent(); HtmlService.toString(); HtmlService.initTemplate(); HtmlService.createHtmlOutputFromFile(); HtmlService.createHtmlOutput(); HtmlService.createTemplate(); Jdbc.newTimestamp(); Jdbc.newTime(); Jdbc.newDate(); Jdbc.parseTime(); Jdbc.getCloudSqlConnection(); Jdbc.parseTimestamp(); Jdbc.toString(); Jdbc.getConnection(); Jdbc.parseDate(); LanguageApp.toString(); LanguageApp.translate(); LinearOptimizationService.createEngine(); LinearOptimizationService.toString(); LockService.getPublicLock(); LockService.toString(); LockService.getDocumentLock(); LockService.getPrivateLock(); LockService.getUserLock(); LockService.getScriptLock(); Logger.clear(); Logger.getLog(); Logger.finest(); Logger.finer(); Logger.config(); Logger.toString(); Logger.severe(); Logger.fine(); Logger.log(); Logger.warning(); Logger.info(); MailApp.getRemainingDailyQuota(); MailApp.createMessage(); MailApp.toString(); MailApp.sendEmail(); Maps.encodePolyline(); Maps.decodePolyline(); Maps.newElevationSampler(); Maps.toString(); Maps.newGeocoder(); Maps.newStaticMap(); Maps.setAuthentication(); Maps.newDirectionFinder(); MimeType.toString(); PropertiesService.getScriptProperties(); PropertiesService.toString(); PropertiesService.getUserProperties(); PropertiesService.getDocumentProperties(); ScriptApp.newStateToken(); ScriptApp.getProjectTriggers(); ScriptApp.newTrigger(); ScriptApp.getOAuthToken(); ScriptApp.getUserTriggers(); ScriptApp.getScriptTriggers(); ScriptApp.getInstallationSource(); ScriptApp.getResource(); ScriptApp.toString(); ScriptApp.invalidateAuth(); ScriptApp.deleteTrigger(); ScriptApp.getService(); ScriptApp.getProjectKey(); ScriptApp.getAuthorizationInfo(); ScriptProperties.deleteAllProperties(); ScriptProperties.getKeys(); ScriptProperties.setProperties(); ScriptProperties.getProperty(); ScriptProperties.toString(); ScriptProperties.deleteProperty(); ScriptProperties.setProperty(); ScriptProperties.getProperties(); Session.getTimeZone(); Session.getScriptTimeZone(); Session.getUser(); Session.getActiveUserLocale(); Session.getActiveUser(); Session.toString(); Session.getEffectiveUser(); SitesApp.getActivePage(); SitesApp.copySite(); SitesApp.getActiveSite(); SitesApp.getPageByUrl(); SitesApp.getSite(); SitesApp.createSite(); SitesApp.getSites(); SitesApp.getAllSites(); SitesApp.toString(); SitesApp.getSiteByUrl(); SoapService.wsdlService(); SoapService.wsdl(); SoapService.toString(); SpreadsheetApp.getActiveSpreadsheet(); SpreadsheetApp.getActiveRange(); SpreadsheetApp.openByUrl(); SpreadsheetApp.setActiveRange(); SpreadsheetApp.create(); SpreadsheetApp.openById(); SpreadsheetApp.open(); SpreadsheetApp.getUi(); SpreadsheetApp.getActive(); SpreadsheetApp.setActiveSpreadsheet(); SpreadsheetApp.flush(); SpreadsheetApp.getActiveSheet(); SpreadsheetApp.setActiveSheet(); SpreadsheetApp.toString(); SpreadsheetApp.newDataValidation(); SpreadsheetApp.openByKey(); UiApp.createApplication(); UiApp.getUserAgent(); UiApp.getActiveApplication(); UiApp.toString(); UrlFetchApp.fetch(); UrlFetchApp.addOAuthService(); UrlFetchApp.toString(); UrlFetchApp.getRequest(); UrlFetchApp.removeOAuthService(); UserProperties.deleteAllProperties(); UserProperties.getKeys(); UserProperties.setProperties(); UserProperties.getProperty(); UserProperties.toString(); UserProperties.deleteProperty(); UserProperties.setProperty(); UserProperties.getProperties(); Utilities.formatDate(); Utilities.computeHmacSha256Signature(); Utilities.zip(); Utilities.sleepAndThrow(); Utilities.computeDigest(); Utilities.jsonParse(); Utilities.base64EncodeWebSafe(); Utilities.unzip(); Utilities.base64Encode(); Utilities.sleep(); Utilities.base64Decode(); Utilities.computeHmacSignature(); Utilities.formatString(); Utilities.base64DecodeWebSafe(); Utilities.newBlob(); Utilities.jsonStringify(); Utilities.toString(); Utilities.validateSleepTime(); Utilities.parseCsv(); Xml.element(); Xml.text(); Xml.declaration(); Xml.parseJS(); Xml.attribute(); Xml.xml(); Xml.xmlns(); Xml.namespace(); Xml.document(); Xml.name(); Xml.empty(); Xml.toString(); Xml.comment(); Xml.parse(); Xml.processingInstruction(); XmlService.createDocType(); XmlService.getCompactFormat(); XmlService.getPrettyFormat(); XmlService.getNoNamespace(); XmlService.getRawFormat(); XmlService.createComment(); XmlService.createDocument(); XmlService.toString(); XmlService.getXmlNamespace(); XmlService.parse(); XmlService.getNamespace(); XmlService.createElement(); XmlService.createCdata(); XmlService.createText(); } 

现在,在脚本中运行或调试任何内容,您将获得超级授权消息。

© www.soinside.com 2019 - 2024. All rights reserved.