Home > Mobile >  Is there a way to eanble Sheet API via Apps Script?
Is there a way to eanble Sheet API via Apps Script?

Time:05-20

I've exploring possibilities here to dimish the workload for users when first running the sets of script I'd have built into the spreadsheet. One of the functions requires Sheets API and having the user manually enable it would be a killer. I've read through it and couldn't find a clear answer as to the possibility to add this advanced service together via script when the user is first authorizing the script to run...

This is what the user would have to do instead: enter image description here

Thanks for your input!

CodePudding user response:

Although, unfortunately, from your question, I cannot know your actual situation, in order to achieve your goal, I thought of the following 3 patterns.

Pattern 1:

In this pattern, Sheets API is directly used.

  • If the Google Apps Script project (GAS project) is the container-bound script, it adds Sheets API to appsscript.json of the GAS project using Google Apps Script API.

    • In this case, it is required to link Google Cloud Platform Project to Google Apps Script Project. Ref
  • If the Google Apps Script project (GAS project) is the standalone script, it adds Sheets API to appsscript.json of the GAS project using Drive API.

By this, Sheets API can be directly used with the GAS project.

Pattern 2:

In this pattern, Sheets API is directly used. The flow of this pattern is as follows.

  1. Prepare a Google Spreadsheet including the container-bound script.
  2. The container-bound script has the script you want to use and Sheets API has already been enabled.
  3. When you want to make users use this script, by copying this Spreadsheet, the user can use the script that Sheets API has already been enabled.

I thought that this pattern might be simpler.

Pattern 3:

In this pattern, Sheets API is indirectly used. The flow of this pattern is as follows.

  1. Create a new Google Apps Script project and enable Sheets API at Advanced Google services.
  2. Deploy the GAS project as the Web Apps.
  3. When you use Sheets API at your GAS project, you can indirectly use Sheets API by accessing Web Apps using the script.
  • In this case, Sheets API has already been enabled at the Web Apps side. So, your GAS project of the client side is not required to enable Sheets API.

  • In this case, also, I think that it is required to check the number of concurrent accesses. Ref

References:

  • Related