3
votes

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?

2
Use an add-on instead of a library. The library is executed with the Cloud Platform project of the host script. Alternately, publish as a standalone webapp and configure your script pattern appropriately (i.e. only serializable function arguments and return types). - tehhowch

2 Answers

1
votes

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.

0
votes

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.