Clasp: Enable Advanced Services for Apps Script projects via CLI

Created on 14 Jun 2018  路  8Comments  路  Source: google/clasp

Expected Behavior

To use Google APIs (Advanced Services) in Apps Script, you must enable APIs in the online editor at script.google.com > Resources > Advanced Google Services...

You should be able to setup a project without having to go to the editor. I propose a function to enable APIs in clasp like the UI.

Commands

clasp apis list
clasp apis enable "drive.googleapis.com"
clasp apis disable "drive.googleapis.com"
  • list would list all Google API serviceIds
  • enable/disable a API for the Cloud project

Eventually autocomplete:

clasp apis enable # select from list of all Google APIs that aren't enabled
clasp apis disable # select from list of enabled APIs in the manifest

API

These commands would use the serviceuser.projects.services API. It would require a personal Cloud project.
projects/project-id-0486239153690933627/services/drive.googleapis.com

EDIT: User serviceusage not serviceuser since that's the newer API.

Result

The result of enabling an advanced service via the UI is:

  1. Enabling the API for your Cloud Console project
  2. Adding some data to your appsscript.json.
  "dependencies": {
    "enabledAdvancedServices": [{
      "userSymbol": "AdSenseOrWhatever",
      "serviceId": "adsense",
      "version": "v1.4"
    }]
  }

Actual Behavior

Users have to go to script.google.com to enable advanced services.

feature request

Most helpful comment

@rdoursenaud Advanced service aren't disabled on push. You need to pull after you enable an advanced service, because it changes the appsscript.json file. LMK if you're still seeing an error.

I should document this more.

All 8 comments

The actual behavior is even more annoying since it disables the advanced services on clasp push!

@rdoursenaud Advanced service aren't disabled on push. You need to pull after you enable an advanced service, because it changes the appsscript.json file. LMK if you're still seeing an error.

I should document this more.

@grant Oh, I see, makes perfect sense. Thanks and sorry about the noise.

No worries, it's not intuitive (see #171).
I probably should add a warning if you try to push before pulling like git.

@grant I don't think you meant to close this issue. Exposing the advanced services feature in CLASP is still a good idea!

Right!

I've authored most of this feature here: https://github.com/google/clasp/commit/faa4337752fee7484160f3fb8b6930c87dce1caf

I need to update the manifest file still.

This feature has been added into master.
It'll appear in clasp@2 in December.
Marking as fixed.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

PopGoesTheWza picture PopGoesTheWza  路  4Comments

nirazul picture nirazul  路  7Comments

OleksandrRakovets picture OleksandrRakovets  路  3Comments

labnol picture labnol  路  4Comments

nmccready picture nmccready  路  5Comments