Key in working with Google Apps Script is to handle things in batches. API calls are time consuming and need to be kept at a bare minimum.
Try applying the following:
- You're trying to retrieve appr. 3000 values by using
getValue()
. Better is to use the getValues()
and add that to an array (all data that is !!). This minimizes API calls by 2999 times; var allData = SpreadsheetApp.getActiveSpreadsheet().getDataRange().getValues()
.
- The same is applicable for the
setValue()
. Here, you can also use setValues()
to batch that process and thus minimizing the API calls.
Furthermore, most of the script is basically the same. Why not squeeze that in a standardized piece of code?
References:
These are instructions for getting the client ID and secret for oAuth.
This explains the process of navigating the Cloud Platform and getting your Apps Script project information including the client ID and secret.
An Apps Script project is initially given a "default" Google Cloud Project, but you will need to create a "standard" Google Cloud Project, and then associate the Apps Script project with the Google Cloud Project. To create a "standard" Google Cloud Project, you must first open the Google Cloud Platform dashboard at:
Google Cloud Platform
Then you need to create a new Cloud Platform Project, get the Cloud Platform Project id number, and add it to the Apps Script Project.
First go to IAM & admin, and choose "Manage resources"
Click "Create Project"
Create a project, and get the id number.
Go back to the Apps Script code editor, and open the Resources menu.
Enter the id number and associate it with the Apps Script project.
- In the "Resources" menu, choose the "Cloud Platform Project" item.
![Cloud Platform Project](https://i.stack.imgur.com/3UUGM.jpg)
Dialog comes up:
![Developers Console Dialog](https://i.stack.imgur.com/zwvOR.png)
Click Blue Link. Developers Console comes up. Navigate to Credentials.
![Navigate to Credentials](https://i.stack.imgur.com/iBi4t.jpg)
In the Credentials page, click on either the Name or the "Edit OAuth Client" (pencil) icon.
![Click on Name in Credentials](https://i.stack.imgur.com/D8CeX.jpg)
Get the client ID and the client secret. You will need this for the oAuth authorization.
![Client ID and Secret](https://i.stack.imgur.com/FlRML.jpg)
You must also enter a Redirect URI:
Quote from Eric Koleda's apps-script-oauth2:
Eric Koleda's apps-script-oauth2
Before you can start authenticating against an OAuth2 provider, you usually need to register your application and retrieve the client ID and secret. Often these registration screens require you to enter a "Redirect URI", which is the URL that users will be redirected to after they've authorized the token. For this library (and the Apps Script functionality in general) the URL will
always be in the following format:
https://script.google.com/macros/d/{PROJECT KEY}/usercallback
Best Answer
No.
See the Tanaike's answer to Is there any limit on number of concurrent hits or simultaneous executions on Google App Script Web App. Summary: web apps set to "run as me" (script owner) will use the owner's quota.