Clone Google Apps Script project with same advanced google services and API - google-apps-script

I want to create multiple copies of google script files using same advanced services, also must enable API at Google developers console.
When I save as new copy, API at Google developers console for the copy doesn't auto-enable.
Because I need a lot of copies so I can't enable API manually for all.
I also tried creating a script as a library to access advanced services, enable API for it. Then other scripts call to the library function. But when I run, every script show message that I need to enable services and API itself.
Is there any solution for this?

You cannot enable APIs for a Google Apps Script project programmatically. When you create a copy of a Google Apps Script project, a new Google Cloud platform project is created.
Even if the advanced Google service settings are copied when making a file copy, the APIs in the new Cloud Platform project must be manually enabled.

This is no more the case with "default" GCP projects.
When you enable an advanced service for your script project in the Apps Script editor, it is automatically enabled in the default GCP project when the script project is saved.
Contrasting with "Standard" GCP project:
When you enable an advanced service in a script project, you must manually enable the corresponding API in the standard GCP project.
However in both cases, the advanced service needs to be enabled.

Related

How to give users access to app script managed by a GCP Project

I have an app script linked to a spreadsheet that has a few functions to automate some processes for users. I recently updated the project to be linked to a standard GCP project I created so I could create OAuth credentials for an unrelated process in this script. However, now when users go to run the functions, they get a 403. Is there a place in the GCP console where I can give them access? I am not using any OAuth credentials for these functions. Just the standard app script interactions with the Google Sheet.
I think when you move to GCP you are required to use OAuth and they have to enter their credentials again. Found in the docs.
You have to configure the OAuth Consent Screen as is explained in the official docs about link a Google Apps Script project to a standard Google Cloud Project --> https://developers.google.com/apps-script/guides/cloud-platform-projects

Can't run scripts anymore due to Error 401: deleted_client The OAuth client was deleted

I linked my google apps script project to a project on GCP. Then I deleted the GCP because I didn't need it. Now, I can't run scripts inside my google apps script project.
First, I got this popup. Then, after clicking the first button I get to error message in my subject line.
Originally, I linked from google apps script to GCP from the Resources/Google Cloud Project option. There is no option to unlink...
How can unlink my Google Apps Script from my now-deleted GCP.
As written in the documentation,
You can't switch a script project to use a default GCP project. Default GCP projects are deleted once the script project they were created for is set to use a standard GCP project.
You cannot unlink as the default project is deleted. You have to create a new GCP project and link to the new project, which will automatically unlink from it's old project.

Stop Apps Script from creating GCP projects

I'm seeing a large number of GCP projects being created by serviceAccount:appsdev-apps-dev-script-auth#system.gserviceaccount.com, following invocation of Apps Scripts.
I'd like to control or block such project creation.
What are the right ways to accomplish that?
That's not possible. Quoting GCP Projects's documentation:
By default GCP projects have an Identity and Access Management (IAM)
policy with one entry, a Google service account that acts as the owner
of the default project. The Google service account is
appsdev-apps-dev-script-auth#system.gserviceaccount.com.
Also:
Every Apps Script project uses the Google Cloud Platform to manage
authorization, Advanced services, and other details. To configure and
manage these settings, every Apps Script project has an associated
Google Cloud Platform project (a GCP project).
You can use a default GCP project or a standard project created by you, but the Apps Script project does need a GCP Project.
Moreover, since April 8, 2019 it's not possible to access the default GCP projects created for Apps Script projects unless they are older.

You cannot switch to an Apps Script-created Cloud Platform project - associate an Apps Script file with Cloud Project

I'm trying to attach a new app script to my Google Cloud project. From the Apps Script code editor, I'm trying to connect to to Cloud Platform project using the Menu:
Resources > Cloud Platform project
but when I add the project number I get the error message
'You cannot switch to an Apps Script-created Cloud Platform project.'
I'm trying to avoid having to create a new Cloud Project, any ideas?
As the error message states, you can't add a new Apps Script to a Cloud Console Project which was created by Apps Script. These Apps-Script created cloud console projects are managed automatically and for whatever reason have this limitation.
Create a new Cloud Console Project manually, then associate your existing apps script project with the manually created cloud console project via the Resources menu in the script editor.

Google App Script LDAP Access Control

Is there a way to restrict access to an application built on Google App Script using LDAP? Can Google App Script access LDAP?
There are a couple of ways to look at this problem.
Apps Script cannot directly access your LDAP system. Apps Script has ability make HTTP calls to REST/SOAP services, make JDBC calls to external databases but it doesn't have built in support for the LDAP directory.
However, if you are using Apps Script w/in a Google Apps domain then you can tie in Google user accounts to LDAP using Google Apps Directory Sync. Once this is setup, you can deploy your Apps Script to only allow people w/in your domain and Google will make them login before they can access the Apps Script.
Hope this helps.