Is it possible to get the names and owners of libraries used in a UiApp (using Google Apps Script)?
Edit-1
In the Script Editor you can click the Resources tab followed by the Libraries... option.
In the dialog you will see a list of libraries you're using.
I would like to obtain that list (including the versions used by the application) plus their owners by code.
not possible. you would need the script file id from drive and use drive api to find its owner. thats not possible, you only have the script project id which is different.
Related
I have a Google Script library that is used by at least 100 other scripts (some that are bound to spreadsheets/documents, some that are not). How can I find all of these client scripts that reference my library script?
More specifically, I need to be able to add a new feature into the library that requires new permissions that I (the user) must grant. The client scripts won't run if I just add this feature to the library without granting the permissions to each of the client scripts. So ultimately, I need to give this new permission to each of the clients. And if I knew what scripts were actually using this library, I could do that manually for each one. But I need to URL's or ID's or something for each of those scripts.
Answer:
Unfortunately this is not possible to do.
More Information
It is possible to get a list of standalone Scripts from your Drive, though scripts bound to a file can not be searched for using regular searching methods.
It is possible, using the help of this Google Account page to get a list of all the Apps that have access to your account, though only files you have authorised will appear here, and apps which are not just those created by you in Apps Script will appear there (for example, other add-ons or even Android Apps bound to your account appear here).
A Partial Workaround:
Using Google Apps Script, you can list all Apps Script Projects that you own with help of the MimeType enumeration GOOGLE_APPS_SCRIPT
var scripts = DriveApp.getFilesByType(MimeType.GOOGLE_APPS_SCRIPT);
var arr =[ ];
while (scripts.hasNext()) {
var script = scripts.next();
arr.push(script)
}
Logger.log(arr);
Or even just searching for type:script in Drive, however this only returns a list of scripts that are not bound to a file.
You can then use regular Google Drive search terms to find which of these files contain, for example, a unique method name that the library uses. I am aware this isn't a perfect solution and you would still have to look for projects bound to a file using the above webpage.
Feature Request:
It appears that back in 2014 a feature request for this was made on Google's Issue Tracker, though I would suggest creating another feature request for this here as it was marked as a duplicate of another issue. You can make a feature request under the correct Apps Script component here.
References:
Google Apps Script - Enum MimeType
Google Drive Search Query Terms
Apps with access to your account
Google's Issue Tracker
Feature Request: Listing and searching for container bound scripts
Create an Apps Script Feature Request
If you publish a Google Apps Script Library are the script quotas applied per library owner or for the library user?
Libraries are not web services. It goes exactly like when you are using client side lib like Jquery.
When you are using an Apps Script lib, you just add extra code to the one in your code editor. So quota is measured against the lib user.
Otherwise it would be impossible to have libs used by many many users :)
Best,
Romain
I am not able to find Adword API support in Google App Script,I can write adword script from adword account but currently i'm handling multiple account(almost 25) what i have to do is go inside individual account and copy my script in that account and adword script have limitation of maximum 15 script can be run by one user at a time, i want to create database of all account at one place that is possible through adword api in java and other programming languages,but i'm quite familiar with Google App script i want to use Adword API in App Script,how can i use UrlFetch() class of Google App Script to use adword api, so that just by replacing client Id of adword account i can get all data at one place(i have access to all account so no need to change username and password).
Thanks in advance for any help and information!
If I understand correctly, the main problem is that you want to to basicaly make a "code library?" So reuse the same bits of code between accounts?
One option is to use the Eval function, as detailed in tip 3 of this article: http://www.ppchero.com/tricks-for-running-adwords-scripts-in-multiple-accounts/. A second example of using this same method is here: http://www.freeadwordsscripts.com/2013/10/use-gdrive-to-load-single-adwords.html
You would then upload this into Google Drive, or point this to the location of the Google Script.
Another option, as detailed in the PPC Hero Article, is to use Google Sheets to pass the variables you need from one script to another. Basically, the SpreadsheetApp function works within all AdWords scripts, so you can use this to pass data along from external sources.
There are some example scripts regarding Adwords associated with these posts:
http://searchengineland.com/four-ways-you-can-benefit-by-using-adwords-scripts-145530
http://googleappsdeveloper.blogspot.co.uk/2012/12/adwords-analysis-in-google-apps-script.html?m=1
I am trying to implement a spreadsheet app using Google Apps Script. But I have several issue that does not mach my requirements. I have looked in to these issues and was unsuccessful to find answers or better alternative ways to implement this functionality.
Requirements:
Write manageable testable code
Not to download the script to each spreadsheet but to somehow when you install once you can use it on any spreadsheet in the drive.
1,2 are the problems I faced.
The Google Apps Script IDE seems to have difficulty in handling a large code base (I mean not to keep the code its about managing and handle the growth of the code)
This is the major problem (Not matching the requirement)
Let's say I create a script for a spreadsheet and then I deploy it and then I can then install the script on any other script I like and then execute it. But this has to be done for each and every spreadsheet. The installed script is not in the script manager to be used in all the spreadsheets without installing the script form the gallery every time.
And also When I create a project of Spreadsheets directly on the Google Drive. Since this is not allocated to a particular spreadsheet it does not allow me to select it from the dive (From script manager) and load this script to a spreadsheet I wish, and run/debug it.
I am not hoping to get a better solution to above issue 1.
But issue No. 2 is is the burning one,
Is this can be addressed to match the requirement?
If the requirement can not be achieved form Google Apps Script, I have to go for an alternative.
Alternatives I thought so far:
I thought about desktop application that can give the spreadsheet URL and then give the authentication information and by using the spreadsheet API do the necessary manipulations form the desktop application. This is the dummy est approach which is not so user friendly.
Go for a Google app, where you can log in using the G mail authentication and then after giving the spreadsheet URL using the Spreadsheet API do the necessary manipulations. But I am not sure about the authentication process for a Google app and the possibility of access permission to the drive.
Final is the Crome app, Where Crome is provided with the necessary authentication to access a given spreadsheet URL and do the necessary manipulations to the spreadsheet.
Which of those options is preferred, or is there any better solution that matches the requirement I stated above?
The definition of "large code base" is subjective, but even a project with several hundred lines of code can benefit from organization. In the IDE you have two primary tools available to help organize your code; Files and Libraries.
This answer is mainly a collection of links to other answers, within a number of topic areas that should address the concerns you've expressed.
Code Organization & Libraries
A script project can have multiple files, of type "gs" (script) or "html". The namespace extends across all script files in the project. Separating methods into files is a simple way to organize your code within a project (for instance, place all tests in one file separate from production code), although it does very little for reusability across projects.
Libraries are projects that are published to enable other projects to incorporate their capabilities without requiring them to copy the actual code. Have a look at the Notable Script Libraries for a start. Libraries take their name space from the library name - for instance, I have a library of utilities related to input & output of CSV files, which I (cleverly) named CSVUtils. The methods in that library are accessed as CSVUtils.example(), and are supported by the auto-complete feature. Libraries support a limited subset of jsdoc, and when published provide a link to the generated documentation.
Organizing Spreadsheet Code in several *.gs files - even possible?
Is it possible to have one script for multiple spreadsheets?
How, or where, do I define a function for use in more than one spreadsheet?
google-apps-script have multiple scripts in one spreadsheet
Creating a namespace-like organization in a google apps script library
Publishing a Google Apps Script Library
Design patterns for libraries in GAS?
ScriptDb in Library accessed by WebApp
Project and multiple doGet() script files published as web apps -- Need clarification
... every SO question about Apps Script Libraries.
Using external JavaScript libraries:
Start by reading through Understanding Caja Sanitization, especially the section regarding External JavaScript Libraries.
Google Apps Script: How can use js library in HtmlService
Authorization & Ownership
Authorization - Google apps script grant user permissions access services on spreadsheet in ther first run without open script editor
https://stackoverflow.com/questions/15096379/google-app-scripts-how-to-let-shared-users-run-scripts-as-themselves
When does Google require re-authentication?
OAuth in Google Apps Scripts Libraries
Code Transparency
Source-code of Libraries used by WebApps visible to everybody?
How to hide library source code in Google way?
Is there a way to use the Google Drive API's from Google Apps Script. I am aware of the DocsList Service, which allows you to look at folders and files , however what about all the other API's in Google Drive (Files,About,Changes,Children,Parents,Permissions,Revisions,Apps,Comments,Replies). For example, is there API access to add Comments to files from Google Apps Script.
Apps Script has the ability to access Google API's, but you need to explicitly enable them before they can be used.
In the code editor, choose RESOURCES, ADVANCED GOOGLE SERVICES
Click the OFF button, to turn the service ON.
Before you close the dialog box, click the link at the bottom to open up the API Manager.
Once you've completed those two steps, the Drive API is available inside of Apps Script. Type the key word Drive then type a period, and available methods will show up in a list.
Methods
get - Gets a file's metadata by ID.
insert - Insert a new file.
patch - Updates file metadata. This method supports patch semantics.
update - Updates file metadata and/or content.
copy - Creates a copy of the specified file.
delete - Permanently deletes a file by ID. Skips the trash.
list - Lists the user's files.
touch - Set the file's updated time to the current server time.
trash - Moves a file to the trash
untrash - Restores a file from the trash.
watch - Start watching for changes to a file.
emptyTrash - Permanently deletes all of the user's trashed files.
https://developers.google.com/drive/v2/reference/files#methods
(Google-Apps-Script=GAS) Drive Services added 2013.05.13 (to be announced at the 2013 Google I/O 2 days later) is apparently-exactly designed to replace the prior API(DocsList) and allow GAS to access the Google Drive SDK, though that functionality is currently not mentioned (why?) from those official docs but it is most certainly suggested by the new new API name "Drive" and is stated at as the purpose by Google's great demo video "Integrate Google Drive with Google Apps Script — Google I/O 2013" and "Drive SDK" is mentioned in by the search functions as searchFiles(String).
And Drive Services works (I'm using it; and though I could think of many improvements, haven't found any bugs of memory) including it works for useful apps (see the the video above for one of the most impressive ones I've seen) but it isn't complete (including doesn't expose the full Drive SDK) including:
it doesn't (yet?) allow one to access prior versions of content (as that vide plus (the enhancement request: Google Search for "Issue 2811: Access the document revisions using DriveApp"),
control the indexing status & method of content,
one can't get a list of a file or folder's accessors (apparently deliberately says the video; but using the prior DocsList or Library mentioned seems like it would be a workaround).
I'd have included more links to help out but I'm a new poster here so the editor's telling me "You need at least 10 reputation to post more than 2 links.".
Yes, it's possible.
Take a look at the documentation for Class File, which includes functions for obtaining and/or changing most of the attributes you've listed.
For an example of code that gets some of this info for files and folders, see this answer.
You should also have a look at this Library written by Romain Vialard, one of the GAS TC.
It provides functions that are not available directly in gas or - at least - not as simply.