Before you can begin the Android or iOS quickstarts, you need a target Apps Script project. The mobile quickstart code executes a function in this project remotely, and receives a response back.
Follow these steps to create a simple script project and enable it for API access.
Step 1: Create the script
- Create a new script project.
- At the top, click Untitled Project to rename the script. Name the script "Apps Script API Quickstart Target" and click Rename.
Replace the contents of the
Code.gs
file with the following:At the top, click Save
.
Step 2: Switch to a user-managed Google Cloud project
Your Apps Script project is automatically associated with a default Apps Script-managed Google Cloud project. To deploy the script for API execution, you need to switch its association to a standard, user-managed Google Cloud project.
- In the Google Cloud console, go to the Manage resources page.
- At the top, click Create Project.
- Enter a project name, choose the parent organization, and select a location folder.
- Click Create.
- In the dialog that appears after the project is created, click Select project.
- On the project dashboard page under Project info, copy the project number.
Step 3: Configure the Google Cloud project OAuth consent screen
To switch your Apps Script's Google Cloud project association, you need to configure the Google Cloud project's OAuth consent screen.
- From the Google Cloud project dashboard page, click Navigation menu > APIs & Services > OAuth consent screen.
- For the purposes of this quickstart, under User type, click External. If you're building an app for only your organization, you can select Internal.
- Click Create.
- Under App information in the App name field, enter "Apps Script API Quickstart Target."
- In the required email fields under User support email and Developer contact information, enter your email. For the purposes of this quickstart, you can leave the other optional fields blank. When you build an app for real-world use, fill out all of the consent screen fields accordingly.
- Click Save and Continue. For the purposes of this quickstart, you can keep clicking Save and Continue until you reach the Summary page. When you build an app for real-world use, fill out all of the pages accordingly.
Step 4: Deploy the script for execution
Now that you've set up your standard Google Cloud project, switch your Apps Script project's Google Cloud project association to use the standard user-managed project and deploy the script.
- In the Apps Script project, at the left, click Project settings .
- Under "Google Cloud Platform (GCP) Project," click Change project.
- In the "GCP project number" field, paste the standard GCP project number you copied in step 2.
- Click Set project.
- At the top right, click Deploy > New Deployment.
- In the dialog that opens, click Enable deployment types > API Executable.
- Under "Description" enter "Target-v1."
- Click Deploy.
Step 5: Choose a quickstart
Each of these quickstarts use the Apps Script API to execute the script you just created: