Cloud Platform Projects

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:

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:

  1. Open the script in the Apps Script editor.
  2. Select Resources > Cloud Platform project.
  3. 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.

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:

  1. Have direct access to the Cloud Platform project settings via the API Console,
  2. Ensure you and your collaborators access to the Cloud Platform project settings of a script residing in a Team Drive, or
  3. 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 calls a script with the Execution 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:

  1. Open the Google API Console.
  2. 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.
  3. 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.
  4. In the upper-right corner, click the More icon icon, and select Project setttings.
  5. Locate and copy the Project Number. You will need this later.
  6. In the Apps Script editor, open the script whose Cloud Platform project you want to replace.
  7. Click Resources > Cloud Platform project.
  8. In the Change Project section, paste the project number you copied into the text field, then click Set Project.
  9. 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.

发送以下问题的反馈:

此网页
Apps Script
Apps Script