Publishing a Google Docs Add on - google-apps-script

I have built a Google Script which is currently bound to my present Google docs document. It is a simple script that has a menu item and a Sidebar. I wish to access it from all my google docs document. I think the way to do it is publishing it on the Chrome Web Store as an add-on. It requires a developer fee of $5 which I have no problem paying but I want my script to be private(or shareable only to selected few) because it contains my API key that I don't want to share.
Please let me know if there is any alternative except publishing it as an add-on
If I publish it, can I use it privately and not share it. if that is true then how to do it.
If there is totally another way to do this, I'm all ears.
Sorry if that is a trivial question, I am a complete beginner.
P.S. I read a few answers saying it can be done but from my knowledge Google has updated the conditions, so wanted to verify before giving the developer fee

Related

Publish as a private add-on to avoid granting permission on copies of gsheets

I have a similar question to both of the questions below. I have a script bound to a google sheets, and I use this sheet as template. However I'm looking for an option to not have to grant permission each time I copy the file.
From reading the answers in the questions below, I understand I have to publish a standalone script as an add-on.
However, reading this answer, I see that I need to create a Cloud Platform Dashboard and all bunch of stuff which looks pretty messy to me, such as google reviewing process. Again, it is only for personal use...
Is there a way I can privately publish it as an add-on, without having to go through all the process?
Thank you
What is the best way to create Container-bound Scripts that can be cloned?
Grant permissions on open for first time for a bound script in Google Sheets
If you don't want spreadsheet hook triggers like onEdit or button or anything else, You can use a standalone script.
A standalone script can be written, which loops through your spreadsheets doing what's needed based on a time trigger.
Adding to the already existing answer
Publishing a private add-on does not require going through the Google Review process, especially since it is for personal use only.
Therefore, the situations below do not require verification:
If you want to deploy the add-on solely for internal use which means that the add on will be used only by people in your Google Workspace or Cloud Identity organization.
If you want to use the add-on domain wide which means that the add on will be used only by Google Workspace enterprise users within the domain.
For the whole list of exceptions from the verification process, you can check this here.
Reference
OAuth API verification FAQs.

reuse script or publish a private google sheets script add-on without gsuite or being a business

I'd like to reuse a Google Apps Script between multiple sheets on my personal Google account without publishing the script publicaly. One approach that I'm trying to avoid is to simply copy and paste the script between each sheet that I'm using.
After some reading my impression is that this is typically done by publishing an add-on. I am also under the impression that this can (or could) be done privately, so that no code review is needed and you don't need to pay anything. Most of the related questions I've found on SO seem to have out of date answers (chrome web store instead of GSuite Marketplace) or are too simple (share by publishing an add-on) or refer to gsuite users/admin, etc.
Assuming I need to publish an add-on to get easy sharing across all of my sheets I'm told I need to convert my project to a Google Cloud Project. So I created a Google Cloud Project and then went to transfer my code to that project by going to "Resources - Cloud Platform project" and entering my project number. However, when I do that it tells me that I need to enable oauth for the project and it takes me to a page which looks like it will require formal code review.
I am under the impression that private publishing may be possible if I am an organization. So I went back to the Google Cloud Console and tried to create an organization. Here however, it seems like either I need to be subscribing to GSuite or I need to enable Cloud Identity. The latter seems only pertinent to businesses as during the sign up it asks me for my business name and business domain (e.g. jims-business.com); I stopped when it asked me for my domain.
So again, my question is, is it possible to share a Google script between multiple sheets on my personal account without making a public add-on? After way to much time reading through Google terminology my impression is no, but I'd be happy to be proven wrong!
You don't need to be a G Suite user to publish an add-on, but you do if you want to do it as "internal only", as it requires a valid domain.
I'm afraid you will have to copy the same Script for each file and use an onOpen function.

Google docs install my own addon without publishing [duplicate]

I have just made an addon for Google docs, successfully tested it and now I would like to use it. It's very simple, it just shows the id of the current document.
This is the most important part of the script, just called by the onOpen(e) function:
DocumentApp.getUi().alert(DocumentApp.getActiveDocument().getId())
When I tested it by the Publish/Test as addon (I am not sure with English titles, I translated the button names from Czech) it works exactly as I want.
How can I use it the same was as I would download it from the webstore? I don't want to publish it, because it isn't much useful for others and I would have to follow the rules, wich Google wants. Is it possible?
You can publish it privately.
This way you can publish it instantly (google doesn't need to review it), it's only visible and install-able by you, and you don't have to pay the developer fee.
In the Chrome Web Store developer Dashboard:
Developer Dashboard
You can add an "Item" to be published as a draft. Then, you can edit the item before publishing it. At the very bottom of the "Edit Item" page, there are 3 settings for visibility options. The last one is "Private"
An Apps Script bound to a Doc runs the onOpen() function without publishing the script as an Add-on, or Deploying the bound script as a web app. Publishing an Add-on, and deploying a web app are two totally different things. But, you don't even need to do either of those. All you need to do, is open the Doc that the Apps Script is bound to, and the onOpen() function will run. Also, you don't need the e argument in onOpen(e). That's for an event parameter.
Something else that's interesting is group based publishing:
Group-Based Publishing in the Chrome Web Store
You can not by pass the payment process i suppose. As earlier comments mentioned; you can pay the developer fee (as i remember it was like a 5 dollars) and publish it as private. So nobody can see and install it.
But if you want to use as test you can run the script as test on a document. Select the "Run->Test as add-on..." menu and you have to select a document. After selecting and openning that document you will see very long text on address bar like this:
https://docs.google.com/document/d/your_document_id/edit?addon_dry_run=bla_bla_bla
So just take the
?addon_dry_run=bla_bla_bla
part after the
https://docs.google.com/document/d/your_document_id/edit
and paste to your other documents :) Your add-on menu will work. But i can not guarantee if that works for only your account or a security leak! Use at your own risk.

How can I let others install my Google Apps Script?

I've made a simple script in Google Apps Script. The script builds forms based on a spreadsheet, the script itself is part of the spreadsheet. It adds a menu item. People would like to use it. They are non-technical people, so I would like to make the installation of my script as easy as possible. With 'installation' I mean a way to 'import' my script into their spreadsheet and automatically set up the needed triggers so the menu item becomes visible. It should be possible for anyone to install it.
I've been thinking of the following solutions:
Publishing as an add-on: my script wouldn't qualify, and even then I can't wait for Google's approval.
Copy-paste. I don't like this, it's way too complicated.
I've looked at this question: https://stackoverflow.com/questions/5334751/how-do-i-share-a-script-i-wrote-with-my-co-workers-on-the-same-google-apps-accou, but the people wanting to install it are not on the same domain in my case. The question is also 3 years old.
EDIT: As it turns out, there doesn't seem to be a solution. I've filed a feature request here: https://code.google.com/p/google-apps-script-issues/issues/detail?id=4122&thanks=4122&ts=1403949074
If your Google Account administrator allows you, you can share scripts/spreadsheets outside your organisation either by sharing directly with another person with a Google Account (Gmail or Google Apps) or by making it public (share with a link or published online).
https://support.google.com/drive/answer/2494822?hl=en
Keep in mind that if you use the Script Properties to store values, each time someone uses the shared script it will overwrite the values. In a shared context it is best to use User Properties instead. This way each user can store their own values.
https://developers.google.com/apps-script/guides/properties
There is no way to import a script in an existing spreadsheet , the "normal" workflow is , in a way, the reverse process, that's to say create a sheet from an existing template that already has the script in it and start to work with that copy.
From your description I'm not sure this method could be useable but I'm afraid there is no other way if you want people who will be using it should not go into the script editor at all.
There would be a couple of functions to write that should run at install time and would create the triggers (if needed) and trigger the authorization process.
I made such a SS some time ago that needed authorizations and I added an "install" menu that made its use quite simple (example here on a friendly hosting site).
I know this is probably not the answer you were expecting but it was definitely too long to fit in a comment anyway.

Scripting Google documents (not spreadsheets) with Google Apps Script

So I know that it's possible to create scripts for use on spreadsheets using Google Apps Script, but is there support for using created scripts on documents? I know that the API provides services for creating and editing documents, though they bear the experimental tag, but I can't seem to find a way to create and install a script on a document.
And when I say document services, I refer to the following link: https://developers.google.com/apps-script/service_document
Update: you can do this now. Just in case someone stumbles on this answer. To clarify the above answer, too: you can create scripts that are attached to documents or standalone scripts. Attached scripts can be published as add-ons, but are always associated with a document (doc, sheet, or form). Standalone scripts can be published as web apps.
You can't find it because you cannot do it. Scripts can indeed manipulate documents using Document services (as you referred to) but the script itself should be linked to a spreadsheet or a Google site. Linked is probably not the best word since the apps script can be published to work as a standalone web application - in this case the link to the spreadsheet is used only during the development of your application.
I hope this makes things clear enough.