Every Apps Script project uses the Google Cloud Platform to manage authorization, Advanced services and other details. A Cloud Platform project (formerly known as a Developer Console project) is used to configure these and other settings.
When an Apps Script project is created, a Cloud Platform project is also created behind the scenes. This default Cloud Platform project is hidden, meaning it does not appear in the list of projects found in the API Console.
Most of the time you never need to see or adjust this hidden Cloud Platform project — Apps Script handles all the necessary interactions with the Google Cloud Platform automatically. However, you do need to update the settings of the hidden project when you do any of the following:
- Enable Advanced Service APIs.
- Execute Apps Script functions via the Apps Script API. Any applications that call an Apps Script project must share a common Cloud Platform project.
- Configure the G Suite Marketplace SDK for domain-wide publishing of an add-on or web app.
- Use Stackdriver Logging.
For these cases, you can access the hidden Cloud Platform project from the Apps Script editor.
In some cases the default hidden Cloud Platform project is insufficient. In those cases you can create a standard Cloud Platform project in the API Console (or use an existing one) and direct an Apps Script project to switch to use the standard Cloud Platform project. This give you more control over your project, but may add unnecessary complexity. Because of this, it is recommended that you use the default Cloud Platform project whenever possible.
Apps Script Cloud projects and Team Drives
Team Drives provide shared spaces where teams can collaborate on documents, including Apps Script projects. This can be valuable when developing scripts, add-on and web apps with a team, but it places some restrictions on what you can do with an Apps Script's Cloud Platform project.
Using a default Cloud Platform project within a Team Drive imposes the following restrictions:
When an Apps Script is created in a Team Drive, you can't access the default Cloud Platform project using the Apps Script UI or the API Console. This prevents you from enabling Advanced Services, configuring an add-on or web app for domain-wide installation, or using Stackdriver logging with that project.
Similarly, when an existing Apps Script project is moved into a Team Drive, similar restrictions are applied. You can't access the script's default Cloud Platform project unless you had access to it prior to it being moved into the Team Drive. For example, if you created a script in your Google Drive and then moved it into a Team Drive so others could collaborate on it, you would still be able to access the script's Cloud Platform project (since you created it), but your collaborators may not be able to.
After an existing script is moved into a Team Drive, whenever a user sees the authorization prompt for that script it is labeled using the script project name at the time of the move. This means if you move a script project into a Team Drive and then change the project's name, users that authorize the script see the old script project name in the authorization dialogs.
An Apps Script's default Cloud Platform project is sufficient for most use cases, even when collaborating in Team Drives. If you want to avoid the above restrictions or if you want direct access to the script's Cloud Project settings in the API Console, you can use a standard Cloud Platform project for your script.
Accessing an Apps Script Cloud Platform project
To view an Apps Script's Cloud Platform project, do the following:
- Open the script in the Apps Script editor.
- Select Resources > Cloud Platform project.
- In the dialog that opens, click the top link, which is typically something like [Script Name] - project-id-123456789012.
This takes you directly to the Cloud Platform project that the script is currently using. You may be asked to accept a terms of service agreement if you have not done so already.
If you have switched an Apps Script project to use a standard Cloud Platform project, that project is accessible in the API Console. Default (hidden) Apps Script Cloud Projects are not presented in this console.
Adding additional owners to a Cloud Platform project
You can add additional owners (or other roles) to an Apps Script project's Cloud Platform account. If you are collaborating on a project, this helps ensure that someone on your team always has access to the script project's Cloud settings.
You can add additional owners or other roles to a Cloud Platform project by doing the following:
- Determine who your collaborators should be. We recommended that you create or use an existing Google Group as your collaborator list. You can also specify domains in the collaborator list to include all users in that domain as collaborators.
- Open the script's Cloud Platform project.
- Click the icon in the upper-left to open the left nav.
- Select IAM & admin > IAM.
- At the top of the window, click the ADD button.
- Follow the on-screen instructions to add one or more new members and their roles to the Cloud Platform project. You can add individual emails, Google Groups, or domains as new members.
- Click Save to record the changes.
Switch to a different Google Cloud Platform project
It is possible to switch a script so that it uses a different, standard Cloud Platform project. This may be valuable if you want to:
- Have direct access to the Cloud Platform project settings via the API Console,
- Ensure you and your collaborators access to the Cloud Platform project settings of a script residing in a Team Drive, or
- Consolidate a script with another existing application, so that they share the same authorization and other settings. This procedure is commonly used to ensure that an app that executes a script with the Apps Script API shares a project with that script. It is also used to bundle an add-on with a G Suite Marketplace app.
To switch a script's existing Cloud Platform project over to another Cloud Platform project, follow these steps:
- Open the Google API Console.
- If you do not yet have a project to switch the Apps Script project to, create one by clicking the drop-down menu next to the Google APIs label in the upper-left, then click Create project. Name the project and click Create.
- In the upper-right corner, there is a drop down menu. The label of this menu may be Select a project, Go to a project, or be the name of an existing project you recently opened in the console. Locate the project you want the script to be associated with and select it. If it isn't in the list, select View more projects and select it from the resulting dialog, then click Open.
- In the upper-right corner, click the icon, and select Project setttings.
- Locate and copy the Project Number. You will need this later.
- In the Apps Script editor, open the script whose Cloud Platform project you want to replace.
- Click Resources > Cloud Platform project.
- In the Change Project section, paste the project number you copied into the text field, then click Set Project.
- A warning screen explains the effects of changing the Cloud Platform project. Read the notice carefully, and click Confirm.
Grouping multiple scripts with a single Cloud Platform project
There may be cases in which you want multiple Apps Script projects to share the same Google Cloud Platform project. Since these default Cloud Platform projects for Apps Scripts are hidden, they cannot be used as the destination projects for a switch. If you see a "Project does not exist or you need edit access to it" error when attempting to switch a script's project, that usually means you are attempting to move it to one of these default projects.
To get around this restriction, create a new, blank Cloud Platform project, and use the steps above to add each script to that.